/* log1.c Jim Plank CS360 September, 1996 */ #include #include #include #include #define LOG_FILE "/blugreen/homes/plank/cs360/notes/Setuid/log_file" write_to_fill_log() { char *username; time_t t; int fd; char s[1000]; char *time_string; username = getenv("USER"); t = time(0); fd = open(LOG_FILE, O_APPEND | O_SYNC | O_CREAT | O_WRONLY, 0666); if (fd < 0) { fprintf(stderr, "Can't write log file %s\n", LOG_FILE); return; } time_string = asctime(localtime(&t)); sprintf(s, "%-10s %s", username, time_string); write(fd, s, strlen(s)); close(fd); } main() { write_to_fill_log(); }