Develop should take a message given as a command

Assignment Help Operating System
Reference no: EM13166732

This assignment should give you experience in using file descriptors, open(), close(), write(), stat() and chmod(), perror(), and command line arguments.

Program

Write a program that will allow you to add messages to a file that has NO permissions for any user.

A Unix system has many files that have sensitive information in them. Permissions help keep these files secure. Some files can be publicly read, but can not be altered by a regular user (ex.: /etc/passwd). Other files can't be read at all by a regular user (ex.: /etc/shadow).

The program you develop should take a message given as a command line argument and append it to a file (also specified on the command line). The file should have no permissions, both before and after the message is appended. Of course, the file should be owned by you.

Your program should also have a -c option that will clear the file before the message is appended.

Algorithm

  1. Check to see if the output file exists. If it doesn't, create it. Life is simpler if a newly created file is closed at the end of this step.
  2. Check the permissions of the output file. If any permissions exist, print a useful error message and exit.
  3. Change the permissions on the file to allow writing by the user.
  4. Open the file for output. If the "-c" command line option is present, make sure the file is truncated.
  5. Write the message from the command line to the output file. Write an additional newline character so that the output has a nicer format.
  6. Clear the permissions and close the file. (These two operations can be performed in either order, but the implementation is slightly different.)

Useful Hints

  • Don't use the command line arguments directly. Their position in the argument list may change depending on options. Create meaningful char*variables and fill these with the appropriate entries from the argument list.
  • Check for error values after nearly every system function call. It's a pain to set up, but it saves time in the long run.

Input

None, really. Just command line arguments.

Error Checking

If the log file cannot be opened, an appropriate error message should be printed and the program should exit. If the file has any permissions at all, the file should be rejected as insecure, and the program should exit.

Reference no: EM13166732

Questions Cloud

8-bit registers are there in the intel 80x86 cpu design : In total, how many 8-bit registers are there in the Intel 80x86 CPU design presented in class? Name one of these 8-bit registers.
Draw pictures of the list names afte : Draw pictures of the list names after each line of the following code. Show the head pointer of the list, and the values and next pointers of every node. Draw pointers as arrows, and the null pointer as a slash or X. You may assume the list is sin..
Implement a game called bunko-poker : Implement a game called Bunko-Poker. The gameplay is an easily programmed version of the popular game Yahtzee. Your program will make use of the supplied static functions Dice.roll() and, in cases where you might need the string ordered, Dice.ordered..
Is problem solving easier and more effective in solving : Is problem solving easier and more effective in solving business problems without information systems or with? (justify your position)
Develop should take a message given as a command : The program you develop should take a message given as a command line argument and append it to a file (also specified on the command line). The file should have no permissions, both before and after the message is appended. Of course, the file sh..
Linked list with first node pointer p. : Complete the code for a function that replaces each occurrence of value x by value y in a linked list with first node pointer p.
Prepare a quarterly income statement : Prepare a quarterly income statement, a statement of retained earnings, and a balance sheet and journalize and post the adjusting entries. In the ledger accounts ( T-accounts), indicate the adjusting entries with an A.
Declare a pointer to an array of 500 school : In a main() demonstration function, declare a pointer to an array of 500 School objects and include code to handle any memory allocation errors that occur. in a loop, declare 500 array objects at a time, continuing to rewrite the main() functions ..
Uses a loop to populate a one-dimensional array : Write the following program that creates and uses a loop to populate a one-dimensional array that holds the even numbers between 1 and 12; creates and uses a loop to populate a second one-dimensional array that holds the odd numbers between 1 and 12;..

Reviews

Write a Review

Operating System Questions & Answers

  Scientific principles behind a computer technology

Explain the scientific principles behind a computer technology and discuss how social, political, economic or ethical impact of computers on our cultural structures and beliefs.

  Question about operating system interfaces

The Internet can be used for several reasons, including research and education, and information can be  achieved  from many types of Web sites.

  Question about sarbanes oxley act in the us

Sarbanes-Oxley Act in the United States has greatly increased the compliance obligations of publicly traded corporations.

  Advantages and disadvantages of major operating system

Consider the advantages and disadvantages of each major operating system that Amy might use on the Web server. In a one-page memorandum to Amy.

  Value in managing security and risk

Explain ISO 27001's value in managing security and risk. What are the drawbacks and benefits for obtaining ISO 27001 certification?

  Standard forms, mdi parent forms and mdi child forms

Explain the similarities and differences between standard forms, MDI parent forms, and MDI child forms in an MDI application. How is each type of form created?

  Show possible interleavings of the execution

A concurrent program with 2-procedure, p and q, defined as follows, A,B,C,D, and E are arbitrary atomic statements. Suppose that the main program does a parbegin of the two procedure.

  Process customer order history from a file

Required help creating a document that Develop an application that will read and procedure customer history order information from a document.

  How many page faults are generated using lru replacement

How many page faults are generated by the following arrayinitialization loops, using LRU replacement, and assuming page frame 1 has the process in it, and the other two are initially empty.

  Creating programs to compute

Compare zero-, one-, two-, and three-address machines through writing programs to compute X = (A+B X C)/D - E X F)

  Compute number of disk tracks traversed by using fcfs-sstf

Compute number of disk tracks traversed by using FCFS, SSTF, SCAN, and LOOK algorithms for series of disk track service request given below.

  Stateful inspection packet filtering routers

Name two benefits of Stateful Inspection Packet Filtering Routers. Name two benefits that firewalls add to a network

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd