From bfeecdbf621106543c5d64a6e7b415270301eeab Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 25 Jun 2010 17:13:57 +0000 Subject: [PATCH] no more minix touch, id --- commands/Makefile | 4 +- commands/id/Makefile | 4 - commands/id/id.c | 153 ------------------------- commands/touch/Makefile | 4 - commands/touch/touch.c | 247 ---------------------------------------- man/man1/id.1 | 34 ------ man/man1/touch.1 | 49 -------- 7 files changed, 2 insertions(+), 493 deletions(-) delete mode 100644 commands/id/Makefile delete mode 100644 commands/id/id.c delete mode 100644 commands/touch/Makefile delete mode 100644 commands/touch/touch.c delete mode 100644 man/man1/id.1 delete mode 100644 man/man1/touch.1 diff --git a/commands/Makefile b/commands/Makefile index 2eeae97b3..5f742a898 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -13,7 +13,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \ ed eject elle elvis env expand factor file \ find finger fingerd fix fold format fortune fsck \ fsck1 ftp101 ftpd200 getty grep gomoku head host \ - hostaddr id ifconfig ifdef indent install \ + hostaddr ifconfig ifdef indent install \ intr ipcrm ipcs irdpd isoread join kill last leave \ lex life loadkeys loadramdisk logger login look lp \ lpd ls lspci M m4 mail make MAKEDEV makewhatis man \ @@ -28,7 +28,7 @@ SUBDIR= aal add_route adduser advent arp ash at autil awk \ sleep slip sort spell split srccrc stat strings strip \ stty su sum svclog swapfs swifi sync synctree sysenv \ syslogd tail talk talkd tcpd tcpdp tcpstat tee telnet \ - telnetd term termcap tget time tinyhalt top touch tr \ + telnetd term termcap tget time tinyhalt top tr \ truncate tsort ttt tty udpstat umount uname unexpand \ uniq unstack update urlget uud uue version vol wc \ whatis whereis which who whoami write writeisofs \ diff --git a/commands/id/Makefile b/commands/id/Makefile deleted file mode 100644 index c0e6aa934..000000000 --- a/commands/id/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -PROG= id -MAN= - -.include diff --git a/commands/id/id.c b/commands/id/id.c deleted file mode 100644 index b1b044f97..000000000 --- a/commands/id/id.c +++ /dev/null @@ -1,153 +0,0 @@ -/* id - return uid and gid Author: John J. Marco */ - -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ -/* ----- id.c ----- */ -/* Id - get real and effective user id and group id */ -/* Author: John J. Marco */ -/* pa1343@sdcc15.ucsd.edu */ -/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ - -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - struct passwd *pwd; - struct group *grp; - uid_t ruid, euid, uid; - gid_t rgid, egid, gid; -#if __minix_vmd - uid_t suid; - gid_t sgid; -#else -# define suid ruid -# define sgid rgid -#endif -#if NGROUPS_MAX > 0 - gid_t groups[NGROUPS_MAX]; - int ngroups; -#else -# define groups (&rgid) -# define ngroups 0 -#endif - int g; - int isug; - int c, uopt = 0, gopt = 0, nopt = 0, ropt = 0; - -#if __minix_vmd - get6id(&ruid, &euid, &suid, &rgid, &egid, &sgid); - isug = issetugid(); -#else - ruid = getuid(); - euid = geteuid(); - rgid = getgid(); - egid = getegid(); - isug = 0; -#endif -#if NGROUPS_MAX > 0 - ngroups = getgroups(NGROUPS_MAX, groups); -#endif - - while((c = getopt(argc, argv, "ugnr")) != EOF) { - switch(c) { - case 'u': - uopt = 1; - break; - case 'g': - gopt = 1; - break; - case 'n': - nopt = 1; - break; - case 'r': - ropt = 1; - break; - default: - fprintf(stderr, "%s: unrecognized option\n", argv[0]); - return(1); - } - } - - if(uopt && gopt) { - fprintf(stderr, "%s: cannot combine -u and -g\n", argv[0]); - return 1; - } - - if((nopt || ropt) && !uopt && !gopt) { - fprintf(stderr, "%s: cannot use -n or -r without -u or -g\n", argv[0]); - return 1; - } - - if(uopt) { - uid = ropt ? ruid : euid; - if (!nopt || (pwd = getpwuid(uid)) == NULL) - printf("%u\n", uid); - else - printf("%s\n", pwd->pw_name); - return 0; - } - if(gopt) { - gid = ropt ? rgid : egid; - if (!nopt || (grp = getgrgid(gid)) == NULL) - printf("%u\n", gid); - else - printf("%s\n", grp->gr_name); - return 0; - } - - if ((pwd = getpwuid(ruid)) == NULL) - printf("uid=%d", ruid); - else - printf("uid=%d(%s)", ruid, pwd->pw_name); - - if ((grp = getgrgid(rgid)) == NULL) - printf(" gid=%d", rgid); - else - printf(" gid=%d(%s)", rgid, grp->gr_name); - - if (euid != ruid) - if ((pwd = getpwuid(euid)) != NULL) - printf(" euid=%d(%s)", euid, pwd->pw_name); - else - printf(" euid=%d", euid); - - if (egid != rgid) - if ((grp = getgrgid(egid)) != NULL) - printf(" egid=%d(%s)", egid, grp->gr_name); - else - printf(" egid=%d", egid); - - if (suid != euid) - if ((pwd = getpwuid(suid)) != NULL) - printf(" suid=%d(%s)", suid, pwd->pw_name); - else - printf(" suid=%d", suid); - - if (sgid != egid) - if ((grp = getgrgid(sgid)) != NULL) - printf(" sgid=%d(%s)", sgid, grp->gr_name); - else - printf(" sgid=%d", sgid); - - if (isug) { - printf(" issetugid"); - } - - if (ngroups > 0) { - printf(" groups="); - for (g = 0; g < ngroups; g++) { - if (g > 0) fputc(',', stdout); - if ((grp = getgrgid(groups[g])) == NULL) - printf("%d", groups[g]); - else - printf("%d(%s)", groups[g], grp->gr_name); - } - } - - printf("\n"); - return(0); -} diff --git a/commands/touch/Makefile b/commands/touch/Makefile deleted file mode 100644 index 8c01abe2f..000000000 --- a/commands/touch/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -PROG= touch -MAN= - -.include diff --git a/commands/touch/touch.c b/commands/touch/touch.c deleted file mode 100644 index b0b366460..000000000 --- a/commands/touch/touch.c +++ /dev/null @@ -1,247 +0,0 @@ -/* Touch - change file access and modification times. - * - * Usage: see end of file - * - * Conforms to P1003.2 draft 10, sec. 4.62, except that time values - * are not checked for validity, but passed on to mktime, so that - * 9301990000 will refer to Apr. 9th 1993. As a side effect, leap - * seconds are not handled correctly. - * - * Authors: Original author unknown. Rewritten for POSIX by - * Peter Holzer (hp@vmars.tuwien.ac.at). - * - * $Log$ - * Revision 1.1 2005/04/21 14:55:35 beng - * Initial revision - * - * Revision 1.1.1.1 2005/04/20 13:33:47 beng - * Initial import of minix 2.0.4 - * - * Revision 1.8 1994/03/17 21:39:19 hjp - * fixed bug with 4-digit years - * - * Revision 1.7 1994/03/15 00:43:27 hjp - * Changes from kjb (vmd 1.6.25.1): - * fixed exit code - * nonstandard flag 0 to make file very old - * - * Revision 1.6 1994/02/12 17:26:33 hjp - * fixed -a and -m flags - * - * Revision 1.5 1994/02/12 16:04:13 hjp - * fixed bug when -t argument was not given - * removed debugging code - * run through pretty to get Minix layout - * - * Revision 1.4 1994/02/07 21:23:11 hjp - * POSIXified. - * - */ - -#define _POSIX_C_SOURCE 2 /* getopt */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define val2(string) ((string)[0] * 10 + (string)[1] - '0' * 11) -#define val4(string) (val2(string) * 100 + val2(string + 2)) - -typedef enum { - OLD, NEW -} formatT; - -char *cmnd; -int no_creat = 0; -unsigned int to_change = 0; -# define ATIME 1 -# define MTIME 2 - -_PROTOTYPE(int main, (int argc, char **argv)); -_PROTOTYPE(int doit, (char *name, struct utimbuf tvp)); -_PROTOTYPE(void usage, (void)); -_PROTOTYPE(time_t parsetime, (const char *string, formatT format)); - -time_t parsetime(string, format) -const char *string; -formatT format; -{ - struct tm tm; - time_t touchtime; - size_t l; - - l = strspn(string, "0123456789"); - if (l % 2 == 1) return -1; - if (string[l] != '\0' && (string[l] != '.' || format == OLD)) { - return -1; - } - if (format == OLD) { - if (l == 10) { - /* Last two digits are year */ - tm.tm_year = val2(string + 8); - if (tm.tm_year <= 68) tm.tm_year += 100; - } else if (l == 8) { - time(&touchtime); - tm = *localtime(&touchtime); - } else { - return -1; - } - } else { - if (l == 12) { - /* First four digits are year */ - tm.tm_year = val4(string) - 1900; - string += 4; - } else if (l == 10) { - /* First two digits are year */ - tm.tm_year = val2(string); - if (tm.tm_year <= 68) tm.tm_year += 100; - string += 2; - } else if (l == 8) { - time(&touchtime); - tm = *localtime(&touchtime); - } else { - return -1; - } - } - tm.tm_mon = val2(string) - 1; - string += 2; - tm.tm_mday = val2(string); - string += 2; - tm.tm_hour = val2(string); - string += 2; - tm.tm_min = val2(string); - string += 2; - if (format == NEW && string[0] == '.') { - if (isdigit(string[1]) && isdigit(string[2]) && - string[3] == '\0') { - tm.tm_sec = val2(string + 1); - } else { - return -1; - } - } else { - tm.tm_sec = 0; - } - tm.tm_isdst = -1; - touchtime = mktime(&tm); - return touchtime; -} - - -int main(argc, argv) -int argc; -char **argv; -{ - time_t auxtime; - struct stat sb; - int c; - struct utimbuf touchtimes; - int fail = 0; - - cmnd = argv[0]; - auxtime = time((time_t *) NULL); - touchtimes.modtime = auxtime; - touchtimes.actime = auxtime; - - while ((c = getopt(argc, argv, "r:t:acm0")) != EOF) { - switch (c) { - case 'r': - if (stat(optarg, &sb) == -1) { - fprintf(stderr, "%s: cannot stat %s: %s\n", - cmnd, optarg, strerror(errno)); - exit(1); - } - touchtimes.modtime = sb.st_mtime; - touchtimes.actime = sb.st_atime; - break; - case 't': - auxtime = parsetime(optarg, NEW); - if (auxtime == (time_t) - 1) usage(); - touchtimes.modtime = auxtime; - touchtimes.actime = auxtime; - break; - case 'a': to_change |= ATIME; break; - case 'm': to_change |= MTIME; break; - case 'c': no_creat = 1; break; - case '0': - touchtimes.modtime = touchtimes.actime = 0; - break; - case '?': usage(); break; - default: assert(0); - } - } - if (to_change == 0) { - to_change = ATIME | MTIME; - } - if (optind == argc) usage(); - - /* Now check for old style time argument */ - if (strcmp(argv[optind - 1], "--") != 0 && - (auxtime = parsetime(argv[optind], OLD)) != (time_t) - 1) { - touchtimes.modtime = auxtime; - touchtimes.actime = auxtime; - optind++; - if (optind == argc) usage(); - } - while (optind < argc) { - if (doit(argv[optind], touchtimes) > 0) { - fprintf(stderr, "%s: cannot touch %s: %s\n", - cmnd, argv[optind], strerror(errno)); - fail = 1; - } - optind++; - } - return fail ? 1 : 0; -} - - -int doit(name, tvp) -char *name; -struct utimbuf tvp; -{ - int fd; - struct stat sb; - - if (to_change != (ATIME | MTIME)) { - - if (stat(name, &sb) != -1) { - if (!(to_change & ATIME)) { - tvp.actime = sb.st_atime; - } else { - tvp.modtime = sb.st_mtime; - } - } - } - if (utime(name, &tvp) == 0) return 0; - if (errno != ENOENT) return 1; - if (no_creat == 1) return 0; - if ((fd = creat(name, 0666)) >= 0) { - if (fstat(fd, &sb) != -1) { - if (!(to_change & ATIME)) { - tvp.actime = sb.st_atime; - } else { - tvp.modtime = sb.st_mtime; - } - } else { - assert(0); - } - close(fd); - if (utime(name, &tvp) == 0) return 0; - } - return 1; -} - - -void usage() -{ - fprintf(stderr, "Usage: %s [-c] [-a] [-m] [-r file] [-t [CC[YY]]MMDDhhmm[.ss]] " - "[MMDDhhmm[YY]] file...\n", cmnd); - exit(1); -} diff --git a/man/man1/id.1 b/man/man1/id.1 deleted file mode 100644 index 4cfbd8184..000000000 --- a/man/man1/id.1 +++ /dev/null @@ -1,34 +0,0 @@ -.TH ID 1 -.SH NAME -id \- print the uid and gid -.SH SYNOPSIS -\fBid\fR -.RB [ \-ugnr ] -.br -.de FL -.TP -\\fB\\$1\\fR -\\$2 -.. -.de EX -.TP 20 -\\fB\\$1\\fR -# \\$2 -.. -.SH EXAMPLES -.EX "id" "Print the uid and gid" -.SH DESCRIPTION -.PP -\fIId\fR prints the current uid and gid, both numerically and symbolically. -If the effective uid and gid are different from the real ones, all of them -are printed. -.PP -If the \fB\-u\fP or \fB\-g\fP option is specified, then \fBid\fP will print -the effective uid or guid number, respectively, on a single line. Combined -with either of those options, the \fB\-n\fP option prints the name instead of -the number, and the \fB\-r\fP option prints the real instead of the effective -uid or gid. -.SH "SEE ALSO" -.BR getuid (2), -.BR getgid (2), -.BR getgroups (2). diff --git a/man/man1/touch.1 b/man/man1/touch.1 deleted file mode 100644 index 284fda089..000000000 --- a/man/man1/touch.1 +++ /dev/null @@ -1,49 +0,0 @@ -.TH TOUCH 1 -.SH NAME -touch \- change file access and modification times -.SH SYNOPSIS -\fBtouch\fR [\fB\-c\fR] [\fB\-a\fR] [\fB\-m\fR] [\fB\-r\fR file] [\fB\-t\fR [CC[YY]]MMDDhhmm[.ss]] [MMDDhhmm[YY]] \fIfile\fR ...\fR -.br -.de FL -.TP -\\fB\\$1\\fR -\\$2 -.. -.de EX -.TP 20 -\\fB\\$1\\fR -# \\$2 -.. -.SH OPTIONS -.FL "\-c" "Do not create the file if it doesn't already exist" -.FL "\-a" "Change access time" -.FL "\-m" "Change modification time" -.FL "\-r file" "Apply time of specified file" -.FL "\-t [CC[YY]]MMDDhhmm[.ss]]" "Apply time specified" -.FL "\-t [MMDDhhmm[YY]]" "Apply time specified (alternate form)" -.SH EXAMPLES -.EX "touch *.h" "Make the \fI.h\fP files look recent" -.EX "touch -t 199610010000 *" "Change date and time of all files in current directory to midnight Oct 1, 1996" -.SH DESCRIPTION -.PP -With no options specified, the times of last modification and last access -are set to the current time. -This command is mostly used to trick -.I make -into thinking that a file is more recent than it really is. -If the file being touched does not exist, it is created, unless the \fB\-c\fR -flag is present. -.PP -The \fB\-a\fR or \fB\-m\fR flag may be used to change only the access or -modification time. The \fB\-r\fR or \fB\-t\fR flag may be used to change -the times to match the times of another file or to a specified time. -.SH "SEE ALSO" -.BR utime (2). -.SH "AUTHOR" -.PP -Original author unknown. Rewritten for POSIX by Peter Holzer -(hp@vmars.tuwien.ac.at). -.\" man page updated by A. S. Woodhull 2005-01-15 - - - -- 2.44.0