Solved

transmit group set to a child under SUN Solaris

Posted on 2002-03-13
4
312 Views
Last Modified: 2013-12-26
SUN Solaris 'exec' system call reset the current group set.

Does anybody know aworkaround for this?

the following chunk of code well explain the problem: the child process does not inherit the additional group. Under Linux and AIX it does, that is the code below works fine.

  if ((ngroups=getgroups(NGROUPS_MAX,array_of_gids))==-1){
    if (!silent)
      perror("ERROR! getgroups");
    return 10;
  }

  /* Add a group to array of groups */
  array_of_gids[ngroups++]= <any group number you like>;
  if (setgroups(ngroups,array_of_gids)==-1){
    if (!silent)
      perror("ERROR! setgroups");
    return 2;
  }

  system("groups");



thank you all
0
Comment
Question by:mliberi
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:ecw
ID: 6868224
err, are you running as non-root with silent != 0
0
 
LVL 3

Author Comment

by:mliberi
ID: 6876557
the chunk of code I submitted runs with effective user id ==0

silent is a flag used to optionally disable printing error messages to stderr. You can assume it to be FALSE.

The program executes the last command 'system("groups")', but the group previously added doesn't appear in the output generated by 'groups' command.
0
 
LVL 5

Accepted Solution

by:
ecw earned 100 total points
ID: 6877036
Yep, I've checked it, and the man page for groups(1).  If you replace system("groups") with system("id -a") you might find it is in fact working.  groups(1) gets its info from /etc/passwd and /etc/group, not the current process context.
0
 
LVL 3

Author Comment

by:mliberi
ID: 6890056
Oooooops

I'm glad to discover that my problem was so simple to solve.
thank you
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now