- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- can a process change it's own group id without sta...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 06:08 AM
тАО04-30-2004 06:08 AM
Is there a way for a process to change it's group ID - WITHOUT replacing the current shell?
- John Kittel
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 06:32 AM
тАО04-30-2004 06:32 AM
Re: can a process change it's own group id without starting a new shell?
If you want to run a program that does a set GID, you could do the following from a shell-
echo "example"
exec /mybin/myprog
Where "myprog" is a small c-program that does a call to setresgid to set your desitred GID. Then you could have "myprog" do an call to execl to launch the program you wish to run.
The drawback to this approach is you can't go back to your original shell since you are not creating new processing, but replacing the current.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 06:37 AM
тАО04-30-2004 06:37 AM
Re: can a process change it's own group id without starting a new shell?
I have not been able to do that but am curious as to why ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 06:38 AM
тАО04-30-2004 06:38 AM
Re: can a process change it's own group id without starting a new shell?
Nice workaround.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 06:54 AM
тАО04-30-2004 06:54 AM
Re: can a process change it's own group id without starting a new shell?
int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
but then it doesn't explain what "gid_t" is. What is it? How do I call setresgid properly? (I understand I need to supply, for example, a value in egid to be the new effective gid.)
In answer to why I want to do this... we have some vendor software that isn't paying attention to the user's secondary group memberships, and it is making it near impossible to use groups to help set up a secure system. The vendor software however does have hooks to allow calling "CLI" commands, so if I can call this C program to change the current process GID I think it will help.
- John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 06:56 AM
тАО04-30-2004 06:56 AM
Re: can a process change it's own group id without starting a new shell?
Rodney's solution is a good work arounf and if I run into a problem like you have will try it. Please keep us posted with the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 07:04 AM
тАО04-30-2004 07:04 AM
Re: can a process change it's own group id without starting a new shell?
It's the type of the variable/argument rgid, etc.
I think I can code the program now...
- John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 07:12 AM
тАО04-30-2004 07:12 AM
Solution/* Be sure to set -DGID=nnn where nnn is desired GID */
#define UVNAME "UV"
#define PATH "/usr/igi/flodata/%s"
#define CMD "/u1/uv/bin/uv"
#include
#include
int x;
main ( argc , argv )
int argc;
char *argv [];
{
char cdentry[40];
char uvname[40];
x = setresgid(GID,-1,-1);
if ( strcmp(argv[1],".") ) {
sprintf( cdentry, PATH, argv[1]);
sprintf( uvname, "%s '* %s'",UVNAME,argv[1]);
x = chdir(cdentry);
if ( x != 0 ) {
fprintf(stderr, "%s not a valid directory\n", argv[1]);
exit(2);
}
}
x = execl ( CMD , uvname, ARG1, ARG2, (char *)NULL);
perror(" Error from execl\n");
}
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 07:21 AM
тАО04-30-2004 07:21 AM
Re: can a process change it's own group id without starting a new shell?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 07:27 AM
тАО04-30-2004 07:27 AM
Re: can a process change it's own group id without starting a new shell?
The benefit of using my program is I control when the files are available to the user. If the user should login on as a regular unix shell, they won't have write access to the database files. I don't want users trying to "vi" one of the database files.
Only the database application is allowed to write to the database files. Thus going through my c-program they have to run the database application to gain access to the files.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2004 07:31 AM
тАО04-30-2004 07:31 AM
Re: can a process change it's own group id without starting a new shell?
Thanks a bunch Rod.
Also, thanks for your answer Clay. I had already looked into /etc/logingroup and tried that. It didn't seem to help. The vendor software still appeared to only use the primary group. I made a hard link of /etc/logingroup to /etc/group. And made sure the test user re-logged in. The process running the application is still unable to use secondary group permissions to access files. Of course it could still be a mistake on my part in setting up the test properly, but tried everything I could think of.
- John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2004 06:37 AM
тАО05-01-2004 06:37 AM
Re: can a process change it's own group id without starting a new shell?
IF the problem is, you have a program that you want a user to run in a special group.
You can setuid group of the program and the user will then be running the program in the group
Example
-r-xr-xr-x 1 transfer special 2973 Apr 28 2003 program
chmod 2555 program
-r-xr-sr-x 1 transfer special 2973 Apr 28 2003 program
Rory
This won't work for shells but you can create C program that calls the shell.