#include #include #include #include #include #include #include #include #include main(int argc, char **argv, char **envp) { time_t timer; int error; char *user; struct passwd *pwd; char s[256]; int id; register char **p1, **p2; char *path="PATH=/usr/bin:/etc:/usr/bsd"; char *cmd="/bin/at.O"; extern char *optarg; extern int optind,opterr; int opt; char *file=NULL; time(&timer); if ( NULL == ( pwd = getpwuid ( id=getuid () ))) { fprintf(stderr, "getpw failed (%s) for %d at %s", strerror(errno), getuid(), ctime(&timer) ); exit(errno); } user = pwd->pw_name; if ( 0 != putenv ( path )) { fprintf( stderr, "putenv failed for %s (%s)\n", user, strerror(errno)); exit(1); } for(p1 = p2 = envp; *p1; p1++) { if (strncmp(*p1, "LD_", 3) != 0 && strncmp(*p1, "_RLD", 4) != 0 && strncmp(*p1, "LIBPATH=", 8) != 0 && strncmp(*p1, "ELF_LD_", 7) != 0 && strncmp(*p1, "AOUT_LD_", 8) != 0 && strncmp(*p1, "IFS=", 4) != 0 ) { *p2++ = *p1; } } *p2 = 0; while ( (opt=getopt(argc,argv,"mf:q:r:l")) != EOF ) { switch(opt) { case 'f': file=optarg; break; default: break; } } if ( file != NULL ) { if ( -1 == access(file, R_OK) ) { perror(file); syslog(LOG_INFO,"%s:%s trying to access %s", "at", user, file); exit(1); } } execve( cmd, &argv[0], p2 ); perror("exec"); exit(1); }