Re: C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Pete Harlan
On Thu, May 16, 2002 at 09:02:25AM +0200, Perceval Anichini wrote: > When you write > argv + 1, the compiler will understand : compute the address > of argv, and add one time the size of the type which is pointed by argv. > I remember to you that argv[1] = argv + 1. Brackets are only syntactic > s

Re: C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Matijs van Zuijlen
On Thu, May 16, 2002 at 06:13:08PM +0930, Tom Cook wrote: > On 0, Perceval Anichini <[EMAIL PROTECTED]> wrote: > [snip] > > > Moreover, argv + sizeof (argv[1]) is equal to argv[4] (as sizeof (char*) = > > 4) ... > > > > > No. If that were so then you could not access the list of arguments > > >

Re: C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Tom Cook
On 0, Perceval Anichini <[EMAIL PROTECTED]> wrote: [snip] > > Moreover, argv + sizeof (argv[1]) is equal to argv[4] (as sizeof (char*) = > 4) ... > > > No. If that were so then you could not access the list of arguments > > to a main function as argv[0], argv[1], argv[2] etc. The compiler > > k

C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Perceval Anichini
>>>execv( argv[1], argv + sizeof( argv[1] ) ); >> Could you explain this? Why would this line be *more* correct than the precedent? > The second version makes the pointer arithmetic explicit and has the > correct type for the second argument. The first involves an implicit > cast from char*

Re: Setting effective UID for a shell script

2002-05-15 Thread Tom Cook
On 0, Nicos Gollan <[EMAIL PROTECTED]> wrote: > On Wednesday 15 May 2002 12:02, perceval anichini wrote: > > > Moreover, argv + sizeof (argv[1]) is equal to argv[4] (as sizeof (char*) = > > 4) ... > > And then a non-32bit system came along... No no no no no, that's why I used sizeof( char* ), s

[OT] Re: Setting effective UID for a shell script

2002-05-15 Thread Tom Cook
On 0, perceval anichini <[EMAIL PROTECTED]> wrote: > > correct, the call should be: > >execv( argv[1], argv[2] ); > > > For the fanatically correct, this might be better: > >execv( argv[1], argv + sizeof( argv[1] ) ); > > Could you explain this? Why would this line be *more* correc

Re: Setting effective UID for a shell script SOLVED

2002-05-15 Thread Kirk Strauser
At 2002-05-15T20:23:39Z, Alex Malinovich <[EMAIL PROTECTED]> writes: > I ended up using su -c for this particular case since the script is > already running as root but now that I know about sudo I've got a dozen > other scripts that I can finally write. Thanks! :) Heh! That's much the same rea

Re: Setting effective UID for a shell script SOLVED

2002-05-15 Thread Alex Malinovich
On Wed, 2002-05-15 at 09:15, Kirk Strauser wrote: > My new favorite answer is "use sudo". It lets you give certain users > permission to execute certain programs (including scripts) as particular > other user, with or without prompting for a password. It's very well > supported across a range o

Re: Setting effective UID for a shell script

2002-05-15 Thread Nicos Gollan
On Wednesday 15 May 2002 12:02, perceval anichini wrote: > Moreover, argv + sizeof (argv[1]) is equal to argv[4] (as sizeof (char*) = > 4) ... And then a non-32bit system came along... -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTE

Re: Setting effective UID for a shell script

2002-05-15 Thread Kirk Strauser
At 2002-05-15T04:05:08Z, Alex Malinovich <[EMAIL PROTECTED]> writes: > How can I set the effective UID for a shell script? I've got a script > which checks if xscreensaver is running and if not, starts it and then > activates it. However, the script always gets run as root (it's being run > as an

Re: Setting effective UID for a shell script

2002-05-15 Thread David Z Maze
Alex Malinovich <[EMAIL PROTECTED]> writes: > How can I set the effective UID for a shell script? I've got a > script which checks if xscreensaver is running and if not, starts it > and then activates it. However, the script always gets run as root > (it's being run as an APM script). This doesn't

Re: Setting effective UID for a shell script

2002-05-15 Thread perceval anichini
> correct, the call should be: >execv( argv[1], argv[2] ); > For the fanatically correct, this might be better: >execv( argv[1], argv + sizeof( argv[1] ) ); Could you explain this? Why would this line be *more* correct than the precedent? Moreover, argv + sizeof (argv[1]) is equ

Re: Setting effective UID for a shell script

2002-05-15 Thread Tom Cook
On 0, "Eric G. Miller" wrote: > On Wed, May 15, 2002 at 05:17:41PM +0930, Tom Cook wrote: > > > However, you are not entirely correct. This does, in fact, compile, > > with the exception of the type of execve for execv. It also, funnily > > enough, doesn't loop infinitely, which makes me think

Re: Setting effective UID for a shell script

2002-05-15 Thread Eric G. Miller
On Wed, May 15, 2002 at 05:17:41PM +0930, Tom Cook wrote: > However, you are not entirely correct. This does, in fact, compile, > with the exception of the type of execve for execv. It also, funnily > enough, doesn't loop infinitely, which makes me think that the execv > call is just failing. I

Re: Setting effective UID for a shell script

2002-05-15 Thread Tom Cook
Hmmm wasn't thinking very hard when I wrote that mail... On 0, "Eric G. Miller" wrote: > On Wed, May 15, 2002 at 04:31:09PM +0930, Tom Cook wrote: > > On 0, Alberto Cabello Sanchez <[EMAIL PROTECTED]> wrote: > > > As far as I know, you can't. I think you have to setuid() and exec() in > > > a,

Re: Setting effective UID for a shell script

2002-05-15 Thread Eric G. Miller
On Wed, May 15, 2002 at 04:31:09PM +0930, Tom Cook wrote: > On 0, Alberto Cabello Sanchez <[EMAIL PROTECTED]> wrote: > > As far as I know, you can't. I think you have to setuid() and exec() in > > a, say, C compiled program. > > No, that's when you want to do it the other way around. No. 'Cause

Re: Setting effective UID for a shell script

2002-05-15 Thread Tom Cook
On 0, Alberto Cabello Sanchez <[EMAIL PROTECTED]> wrote: > As far as I know, you can't. I think you have to setuid() and exec() in > a, say, C compiled program. No, that's when you want to do it the other way around. If you are root and want to run it as someone else, then: su -c will do it w

Re: Setting effective UID for a shell script

2002-05-15 Thread Alberto Cabello Sanchez
As far as I know, you can't. I think you have to setuid() and exec() in a, say, C compiled program. El Tue, May 14, 2002 at 11:05:08PM -0500, Alex Malinovich escribió: > How can I set the effective UID for a shell script? I've got a script > which checks if xscreensaver is running and if not, star

Re: Setting effective UID for a shell script

2002-05-14 Thread Travis Crump
Alex Malinovich wrote: How can I set the effective UID for a shell script? I've got a script which checks if xscreensaver is running and if not, starts it and then activates it. However, the script always gets run as root (it's being run as an APM script). This doesn't work if I'm logged in as my

Setting effective UID for a shell script

2002-05-14 Thread Alex Malinovich
How can I set the effective UID for a shell script? I've got a script which checks if xscreensaver is running and if not, starts it and then activates it. However, the script always gets run as root (it's being run as an APM script). This doesn't work if I'm logged in as myself since xscreensaver w