Sponsored Content
Special Forums UNIX and Linux Applications Edit/update an /etc/group database entry (c/c++) Post 302201601 by mekos on Monday 2nd of June 2008 03:41:14 PM
Old 06-02-2008
Edit/update an /etc/group database entry (c/c++)

Hello

I'm writing a program for managing accounts and groups in a linux system.
My problem is how to update the members of a group in the /etc/group file,if i have to add/remove those members.

total 3 variables for adding some new members to the group :

Code:
char **oldmembers=grp->gr_mem;        //members before 
char **newmembers;      //new members to be added
char **totalmembers;     //total members (new_old)

while *(oldmembers)
{
*totalmebers=*oldmembers;
totalmebers++
oldmembers++
}

I cant figure out how to continue using the totalmembers pointer from the point it stopped inside the while loop,to add the newmembers now
e.g
Code:
 while *(newmembers)
{
*totalmebers=*newmembers;
totalmebers++
newmembers++
}

so i the end i could have the total memebrs in order to use the setgrnam(struct group *grp) to parse the updated group struct


any help would be appreciated (and any different approach too)
Thanks
 

10 More Discussions You Might Find Interesting

1. SCO

Terminal Control Database Entry

Hi, can someone pls help resolves this problem. I have an Openserver 5.0.4 running but had this error after having a power failure problem. error: cannot access termainl control database entry I have a arnetport also install with wyse 60 terminals, non of the users can have access on... (2 Replies)
Discussion started by: kayode
2 Replies

2. Solaris

entry in /etc/group too long - problem using sudo with %group

hi folks, I've been googling for quite some time, but still can't find anything near it...my problem is the following: for useradministration in our company we are using ssh/sudo, now whenever I try to add users (we have quite a number of users) with useradd -G groupname for secondary group I... (4 Replies)
Discussion started by: poli
4 Replies

3. Programming

userpw.h AIX ( delete entry from the shadow password database )

HI i need to delete an entry in /etc/security/passwd. can't find a way to do it with userpw.h api ( AIX ). the passwd file i delete like this. Write all entrys to passwd file except the one we are removing. can't find any function that works like getspent / getpwent do in AIX userpw api.... (4 Replies)
Discussion started by: nighter
4 Replies

4. Shell Programming and Scripting

Edit entry if not equal

Ok here's the scenario, i have a ll.conf file and masterlist. #cat ll.conf 123456 banner 1234 abcdefghi #cat masterlist abcdefghi banner 123456789 what script to change ll.conf banner 123456789 from banner 1234 if they are not equal. the final output will looks like this. #cat... (4 Replies)
Discussion started by: kenshinhimura
4 Replies

5. Shell Programming and Scripting

shell script to edit file and delete entry

Can anyone provide me a shell script to edit a xml file and delete one entry. To do manually i can edit(vi editor) the file and 'dd' will delete the file.But I wiluld to know if I can do with a script. Thanks in advance Tannu (6 Replies)
Discussion started by: tannu
6 Replies

6. UNIX for Dummies Questions & Answers

is it really not possible for me to edit the etc/group & the etc/passwd files?

From what I have read it possible to create a new group by editing the etc/group and etc/passwd in UNIX two files but a non-experienced user may face many problems such as destroying the file by mistake ot that his changes to these file does not make any difference. However, there is this... (2 Replies)
Discussion started by: whatev3r
2 Replies

7. Shell Programming and Scripting

Edit date entry inside a file

Hi All, I wanted to edit the date value located at /var/opt/CPsuite-R65/fw1/conf/local.scv. The date entry looks like this : :Signature (">=20100717") How can I update the date value by 1 day every other day while preserving the margins of the whole file in a shell script? I have... (5 Replies)
Discussion started by: achillesxv
5 Replies

8. UNIX for Dummies Questions & Answers

Discover the last user in a group to edit a file?

Alright, so a number of users are in a group, and they have certain access rights to a file, which is owned by a single user, standard stuff, right? However, I need to know which user in that group was the last user to edit a file. Is there any way to determine this in SunOS 5.9? I've looked... (5 Replies)
Discussion started by: rainedragon
5 Replies

9. Shell Programming and Scripting

Find similar entry in a .txt file acting as a database.

May i know how do i go along finding similar entry in a .txt file, which is used a as a "database" and post and error saying the entry existed when we key in the entry. ---------- Post updated at 05:18 PM ---------- Previous update was at 05:16 PM ---------- i mean post an error saying the... (5 Replies)
Discussion started by: santonio
5 Replies

10. Shell Programming and Scripting

How to edit file to have one line entry?

Hello All, My file content is: DROP TABLE "FACT_WORLD"; CREATE TABLE "FACT_WORLD" ( "AR_ID" INTEGER NOT NULL, "ORG_ID" INTEGER NOT NULL ) DATA CAPTURE NONE COMPRESS YES; I want to change this file to have entries in one... (6 Replies)
Discussion started by: akash2508
6 Replies
remove group(1m)														  remove group(1m)

NAME
remove group - Removes all group members and the group from the specified name service entry SYNOPSIS
rpccp remove group group-entry-name [-s syntax] OPTIONS
Indicates the name syntax of the entry name (optional). The only value for this option is the dce name syntax, which is the default name syntax. Until an alternative name syntax becomes available, specifying the -s option is unnecessary. ARGUMENTS
Indicates the name of the target group. For an entry in the local cell, you can omit the cell name and specify only the cell-relative name. DESCRIPTION
The remove group command removes a group from the name service database. The group need not be empty. The entry name of the group is required. Privilege Required You need write permission to the CDS object entry (the target group entry). NOTE
This command is replaced at Revision 1.1 by the dcecp command and may not be provided in future releases of DCE. EXAMPLES
The following commands run RPCCP and remove the group from the name service entry /.:/LandS/anthro/Calendar_group: $ rpccp rpccp> remove group /.:/LandS/anthro/Calendar_group RELATED INFORMATION
Commands: add member(1m), remove member(1m), show group(1m) remove group(1m)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy