[Solved] CSE381-Homework2-program to print group membership

$25

File Name: CSE381-Homework2-program_to_print_group_membership.zip
File Size: 471 KB

SKU: [Solved] CSE381-Homework2-program to print group membership Category: Tag:
5/5 - (1 vote)
Objective
The objective of this part of the homework is to develop 1 C++ program to: Understand the use of uid and gid in Linux (input data files are in the same format as /etc/passwd and /etc/group) Gain familiarity with development and testing of C++ programs Understand concepts of stream and file processing. Review basics of problem solving Understand the use of std::unordered_map

Develop program to print group membership

Objective

The objective of this program is to print login-IDs of the users belonging to a given set of gids specified as command-line arguments. The necessary data is read from 2 given text files.

Background

In Linux, users are internally represented using a unique number called user ID of uid. Moreover, a set of users can be logically organized into a group. Such groups are represented by a group ID or gid. Typically, these numbers are seldom used and instead a name is associated with these numbers and the names are often used. This program will serve as an excellent tool to quickly identify membership in a given group.

Data file formats

Prior to solving any problem is important to study the supplied data. So ensure you view the data files (yes, of course you can do this in NetBeans). The supplied data files used are nearly in the same format as they are in a real Linux OS as described below. Needless to add, you will need to copy these files to your NetBeans project in order to read/use them.

  • User data (passwd): The supplied passwd file contains user information in the following colon (:) delimited format:

loginID:passkey:uid:

For example the following line from passwd raodm:xyz:1000: contains the login ID raodm as the first entry, xyz is some passkey (not used) followed by the uid (int). Rest of the information in the line is not used.

  • Group information (groups): The supplied groups file contains group information in the following colon (:) delimited format:

groupID:passkey:gid:members

For example the following line from groups staff:x123:3:1002,1000 contains the group ID staff as the first entry, x123 is some passkey (not used)

followed by the gid (int), followed by a comma separated list of uids. This results in

group corresponding to output 3 = staff: lewisjp3(1002) raodm(1000), where the uid for each member is shown in parentheses.

Sample outputs

One you have completed your program, you can test its operation using the command shows below and compare your output to the output shown below. Note that group IDs are

Base case #1:

$ ./raodm_hw2 0

0 = root: root(0)

Base case #2:

$ ./raodm_hw2 1 1 = bin:

Test case #3 [Must pass to earn full points]:

$ ./raodm_hw2 100

100 = Group not found.

Test case #4 [Must pass to earn full points]:

$ ./raodm_hw2 0 1 2 6 100 6 2 0 = root: root(0) 1 = bin:2 = faculty: raodm(1000) campbest(1001) kiperjd(1003) raychov(1004) bachmaer(2000) inclezd(1500) davisk4(2001) femianjc(2002) crossv(2010) castroa(2011) ahmede(2012)6 = theory: davisk4(2001) inclezd(1500) raychov(1004) femianjc(2002)100 = Group not found.6 = theory: davisk4(2001) inclezd(1500) raychov(1004) femianjc(2002) 2 = faculty: raodm(1000) campbest(1001) kiperjd(1003) raychov(1004) bachmaer(2000) inclezd(1500) davisk4(2001) femianjc(2002) crossv(2010) castroa(2011) ahmede(2012)

Notes/Tips:

  • Use std::istringstream to process each line. See example in slides on processing Comma Separated Values (in this example, instead of comma you are using colons)
  • Use a unordered_map to store uidloginID information to ease look-up from processing group membership.
  • It would be easier to compute and store the line of output to print for each gid in another unordered_map.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE381-Homework2-program to print group membership
$25