Problems with execl("bin/csh", ...) in my OWN shell from login

matt robinson yakker at ucrmath.ucr.edu
Tue Mar 19 00:32:11 AEST 1991


In article <12602 at ucrmath.ucr.edu> yakker at ucrmath.ucr.edu writes:
>The problem I'm having is that I need to start up a new /bin/csh from my
>/bin/eggsh, which is designed to keep the user 'guest' out of the machine
>if he is coming from an invalid host (and not from the console.)  The problem
>is in the function startup() in the code included here, which will hang from
>login.  The user with the /bin/eggsh who comes in from a valid host just hangs
>without going into a new /bin/csh.

Well, this was my own article, and I didn't have anyone reply to it (except
for two individuals, whose answers didn't work.)  Can someone out there come
up with any reasonable answer?  Is there any systems administrator willing
to put forth the effort and try this on their machine?

The suggestions given were to try execl("/bin/csh", "-csh", (char *)0),
or execl("/bin/csh", "-", (char *)0), both of which do not work.
I would appreciate your time and patience, and thanks again, NetLand!

--Matt

______________________________________________________________________________
Matt D. Robinson                                 "...if I only had a brain..."
Systems Programming Group, UC Riverside     -- The Scarecrow, The Wizard Of Oz
Internet : yakker at ucrmath.ucr.edu       UUCP : ..!ucsd!ucrmath!{yakker,source}


INCLUDED FILE AGAIN:
--------------------

------------BEGIN INCLUDED CODE------------BEGIN INCLUDED CODE-----------
/*
// Subject : Problems with execl("bin/csh", ...) in my OWN shell from login
*/
#include <stdio.h>
#include <utmp.h>

#define UTMP		"/etc/utmp"
#define ENTRY_MACH	"/etc/disabled"

#ifndef TRUE
#define TRUE		0
#define FALSE		1
#endif

#ifndef BUFSIZ
#define BUFSIZ		1024
#endif

int check_machines(char *host)
{
	FILE *fp;
	char *str;

	if ((fp = fopen(ENTRY_MACH, "r")) == NULL) return FALSE;
	while (!feof(fp))
	{
#ifndef lint
		str = (char *)malloc(BUFSIZ);
#else
		str = NULL;
#endif
		(void)fgets(str, BUFSIZ-1, fp);
		str[strlen(str) - 1] = '\0';
		if (!feof(fp))
		{
			if (!strcmp(host, str))
			{
				(void)fclose(fp); (void)free(str); return TRUE;
			}
		}
		(void)free(str);
	}
	(void)fclose(fp);
	return FALSE;
}

/*
// HERE IS THE PROBLEM.
*/
void startup()
{
	/*
	// Even if I do the execl("/bin/csh", ...) with a "-csh", or a "-",
	// it does not work.  WHY?
	*/
	(void)execl("/bin/csh","-csh",(char *)0); 
}
/*
// END PROBLEM
*/

int main() 
{ 
	FILE *fp;
	struct utmp ut;
	char *console = "console";

	if ((fp = fopen(UTMP, "r")) == NULL) startup();
	while (fread((char *)&ut, sizeof(struct utmp), 1, fp) == 1) 
	{
		if ((!strcmp(ut.ut_name, "guest")) && (strcmp(ut.ut_line, console)))
		{
			if (check_machines(ut.ut_host) == TRUE)
			{
				(void)fclose(fp);
				(void)fprintf(stderr, "No modem logins.\n");
				exit(1);
			}
		}
	}
	(void)fclose(fp);
	fprintf(stderr, "You look okay to me.  You can login.\n");
	startup();
}
-------------END INCLUDED CODE--------------END INCLUDED CODE------------



More information about the Comp.unix.programmer mailing list