Re: script execute permission without read permission
- From: Unruh <unruh-spam@xxxxxxxxxxxxxx>
- Date: Sun, 30 Mar 2008 21:33:54 GMT
Jamie Smith <jamie-77@xxxxxxxx> writes:
On Mar 29, 11:52 pm, Unruh <unruh-s...@xxxxxxxxxxxxxx> wrote:
No. The wrapper MUST be a binary file, not a script itself. Bash refuses to
allow suid/sgid from a script for obvious security reasons.
Well, now I have compiled "wrapper" from this code:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string>
int main(int argc,char**argv){
if (argc<2) exit(-1);
char cmd[1000];strcpy(cmd,"/bin/sh ");strcat(cmd,argv[1]);
return system(cmd);
}
And you got this wrapper code from where? It does not change the uid.
And you certainly do NOT want it running /bin/sh. That is horrible and a
total security hole.
If you really want a wrapper script here is one
***************************************************
#include <signal.h>
#include <sys/param.h>
#include <stdio.h>
#include <pwd.h>
static char
*trusted_env[]={"PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/local/bin",0};
main(int argc, char * argv[])
{
struct passwd *pwd;
int i;
uid_t uid;
for (i=0;i < NSIG;i++){ if(i!= SIGKILL && i!=SIGCHLD)
{(void) signal(i,SIG_IGN);}
}
uid=getuid();
if ( (pwd = getpwuid(uid))== (struct passwd *)0 )
exit(1);
setuid((uid_t)0);
//perror("setuid: ");
if (argc==2)
{ execle("/usr/local/bin/net","/usr/local/bin/net",argv[1],(char
*)0,trusted_env);
perror("Failed ");
}
setuid(uid);
fprintf(stderr,"network [up|start|down|stop] \n
%d\n",argc);
exit(1);
}
*****************************************8
(This happened to be a wrapper called network for a script called net with
one argument)
Permissions are set exactly as in my previous posting. The error is
the same:
jamie@desktop:~$ ./wrapper script
/bin/sh: Can't open script
Did you mean that bash scripts can't be used this way? Making wrapper
binary didn't change a thing. Would it help to replace the test script
with a C# script and make "wrapper" execute the C# interpreter?
And you expected it to? Read that next sentence again.
That wrapper must do a change of group and must be set up as sgid for thatWhat do you mean by "must do a change of group"? "script" and
group.
"wrapper" are already in specialg, which has execute permissions on
"script":
--wxr-xr-- 1 jamie specialg 86 2008-03-29 21:16 script
-rwxr-xr-x 1 jamie specialg 7339 2008-03-30 21:28 wrapper
Maybe you need to learn something then.
Note my script changes the user not the group, to user 0 (ie root). You
have to ammend that script appropriately.
.
- Follow-Ups:
- Re: script execute permission without read permission
- From: Kees Theunissen
- Re: script execute permission without read permission
- References:
- script execute permission without read permission
- From: Jamie Smith
- Re: script execute permission without read permission
- From: Kees Theunissen
- Re: script execute permission without read permission
- From: Jamie Smith
- Re: script execute permission without read permission
- From: Unruh
- Re: script execute permission without read permission
- From: Jamie Smith
- script execute permission without read permission
- Prev by Date: Re: How do I use the Open Sound System?
- Next by Date: Stats comp.os.linux.misc (last 7 days)
- Previous by thread: Re: script execute permission without read permission
- Next by thread: Re: script execute permission without read permission
- Index(es):
Relevant Pages
|
|