/* * SPDsoft 1997 * Tue May 27 18:32:05 DST 1997 * * Raw print handler access */ #include #include #include #include #include #include #define PATH_SEP '/' #define MAX_ARG 256 #define MAX_REMAP (1) char *app; int safe_str_scan(unsigned char * string, int max_length, int *length); int main(int argc, char **argv, char **envp); void usage(void); void usage(void) { fprintf(stderr,"Use: %s\n", app); exit(0); } int main(int argc, char **argv, char **envp) { register char **p1, **p2; int p; int check; int length; char *cmd[] = { "/usr/lib/print/phandler","-Pmejor","-K","-B65536", NULL }; if ((app = strrchr(argv[0], PATH_SEP)) != NULL) app = app+1; else app = argv[0]; if ( argc != 1 ) usage(); 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; /* lp:x:9:9:Print Spooler Owner */ if( 0 != setuid((uid_t) 9)) { fprintf(stderr, "%s: setuid failed (%s)\n", app, strerror(errno)); } execve( cmd[0], cmd, p2 ); perror("execve"); exit(5); }