View Single Post
  #1   (View Single Post)  
Old 29th June 2011
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default Running a command as a different user w/o starting the login shell

Is there a straightforward manner?

I know about su -c user, but that will try to start the login shell. If the login shell is set to /sbin/nologin (As it often is for cron/daemon users) it won't work.

I actually solved this problem already using a very simple C program using setgid(), setuid(), and system(). But I find it hard to believe that I'm the first one with this issue and that this is the easiest way ...
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote