SUMMARY (for real this time): need help with 'execl(3V)'

From: Joel L. Seber ... CH210 (JLS2013@TNTECH.BITNET)
Date: Sat Oct 17 1992 - 23:37:51 CDT

First, I am VERY SORRY about retransmitting my original query again... I was
attempting to send this summary, but had to abort the message...
unfortunately, the ORIGINAL retransmitted. Please delete it!!!
The solution was staring me in the face the entire time and I missed it...
My original query (for those who like to have the original with the summary):
Running SUNOS 4.1.1b on Sparcstations 1, 1+, 2, IPC, all networked, NIS.
I need some assistance with the 'execl(3V)' command. I am attempting to
write a front-end for 'rlogin' and 'rsh' to restrict their usage to our
local net (I know about group access, but this is an entirely different
problem). The front-end is in C, and my parameter parser works fine.
My problem is when I try to call /usr/ucb/rlogin (haven't gotten to rsh yet)
with 'execl'. My call looks like this:
if ( ok == 'y' )
    *++argv; /* to remove my program name */
    execl("/usr/ucb/rlogin", argv);
as specified in the man page. If I send one parameter as in
% myrlogin machinea
everything works fine. If I send any more than one parameter, as in
% myrlogin -8 machinea
I get the usage message from 'rlogin' as if I had sent a wrong parameter.
I have even tried this with the straight 'exec' call and sending exactly the
parameters in the second example and terminating with a null ( (char *)0 ).
That also failed exactly as above.
I even print the parameters I send before sending to make sure that they are
Any clues? I am at my wit's end on this one.
Please send any replies to me directly and I will summarize.
And here is the summary:
Almost everyone who responded to this point got it right (and also realized
I had made the mistake I pointed out in my earlier message of today), that I
didn't note the significance of argv[0] as HAVING to hold the name of the
program being executed, even though the first parameter of 'execv' was the
name of the ACTUAL program to be executed... The C books I have and the man
page weren't exactly clear on that point, at least not to me. Anyway, this
is the fix:
if ( ok == 'y' )
/* *++argv; /* to remove my program name */ <-------------
    execl("/usr/ucb/myrlogin", argv);
In other words, don't remove argv[0], and rename 'rlogin' to something else,
preferably someWHERE else, with perhaps different privs, etc. I intend to
experiment further with this, but you have gotten me past a problem I would
not have seen the solution to in a hundred years due to the fact that it was
so simple...
Many thanks to the following: William LeFebvre Daniel Edward Lovinger Scott Schwartz Chris Keane Tom Crummey Gene Rackow (thanks for the security docs!) Mark R Wallen Poul Sorensen (thanks for the detail!)
Joel L. Seber | Dry humor is wasted around here.
SUN Workstation Laboratory Manager |
Center for Manufacturing Research | -Joel L. Seber
      and Technology Utilization |
Tennessee Technological University | recursive, adj.
Cookeville, TN 38505 | See 'recursive'
                                        | |

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:52 CDT