diff options
author | as145665 <none@none> | 2007-08-01 09:39:28 -0700 |
---|---|---|
committer | as145665 <none@none> | 2007-08-01 09:39:28 -0700 |
commit | 3d63ea05cb8474d8036d3588cf8299306a994b8c (patch) | |
tree | 6999ef2c95264a88b5563aae521c2147f6a0f557 /usr/src/cmd/cron | |
parent | eb7b3d20d8e5dd688cd7c5f0bc3d4469e92e1c7b (diff) | |
download | illumos-joyent-3d63ea05cb8474d8036d3588cf8299306a994b8c.tar.gz |
6214247 Solaris 10_74 L1: problem when running commmands in interactive mode on solaris
6528610 xargs -p does not work in some locales
Diffstat (limited to 'usr/src/cmd/cron')
-rw-r--r-- | usr/src/cmd/cron/Makefile | 45 | ||||
-rw-r--r-- | usr/src/cmd/cron/atq.c | 10 | ||||
-rw-r--r-- | usr/src/cmd/cron/atrm.c | 46 | ||||
-rw-r--r-- | usr/src/cmd/cron/cron.h | 8 | ||||
-rw-r--r-- | usr/src/cmd/cron/cron.xcl | 20 | ||||
-rw-r--r-- | usr/src/cmd/cron/crontab.c | 67 |
6 files changed, 101 insertions, 95 deletions
diff --git a/usr/src/cmd/cron/Makefile b/usr/src/cmd/cron/Makefile index 12970e35d0..8fcc9f240d 100644 --- a/usr/src/cmd/cron/Makefile +++ b/usr/src/cmd/cron/Makefile @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -34,7 +34,7 @@ MANIFEST = cron.xml ROOTMANIFESTDIR = $(ROOTSVCSYSTEM) ROOTMETHOD = $(ROOTLIBSVCMETHOD)/svc-cron -CPPFLAGS += -D_FILE_OFFSET_BITS=64 +CPPFLAGS += -D_FILE_OFFSET_BITS=64 -I $(SRC)/common/util ROOTVAR = $(ROOT)/var @@ -54,8 +54,9 @@ SCRIPT = batch XPG4SCRIPT = batch.xpg4 POFILE= $(PROG1)_cmd.po -POFILES= at.po crontab.po funcs.po batch.po -XGETFLAGS= -a -x $(PROG1).xcl +POFILES1= at.po crontab.po funcs.po batch.po +POFILES= $(POFILES1) atrm.po +$(POFILES1) := XGETFLAGS= -a -x $(PROG1).xcl ROOTDIRS = $(ROOTSPCRON) $(ROOTCROND) \ $(ROOTCRONTABS) $(ROOTATJOBS) @@ -68,15 +69,19 @@ ROOTPROG = $(PROG1:%=$(ROOTUSRSBIN)/%) $(PROG2:%=$(ROOTBIN)/%) \ ROOTSYMLINK = $(ROOTLIBCRON) $(ROOTETC)/cron +GETRESPSRC= $(SRC)/common/util/getresponse.c +GETRESPOBJ= getresponse.o COMMONOBJ1= permit.o COMMONOBJ2= funcs.o COMMONOBJS= $(COMMONOBJ1) $(COMMONOBJ2) CRONOBJS= cron.o elm.o ATOBJS= at.o att1.o att2.o XPG4OBJS= values-xpg4.o -ATRMOBJS= atrm.o +ATRMOBJS1= atrm.o +ATRMOBJS= $(ATRMOBJS1) $(GETRESPOBJ) ATQOBJS= atq.o -CRONTABOBJS= crontab.o +CRONTABOBJS1= crontab.o +CRONTABOBJS= $(CRONTABOBJS1) $(GETRESPOBJ) # /usr/xpg*/bin/crontab isn't linked with values-xpg*.o since it isn't # required by any specific behavior differences; this makes these @@ -97,16 +102,14 @@ crontab := POBJS = $(CRONTABOBJS) $(COMMONOBJS) crontab.xpg4 := POBJS = $(XPG4CTOBJS) $(XPG4COMMONOBJS) crontab.xpg6 := POBJS = $(XPG6CTOBJS) $(XPG6COMMONOBJS) -at.o objs.xpg4/at.o funcs.o objs.xpg4/funcs.o objs.xpg6/funcs.o permit.o \ -objs.xpg4/permit.o objs.xpg6/permit.o crontab.o objs.xpg4/crontab.o \ -objs.xpg6/crontab.o elm.o := CFLAGS += $(CCVERBOSE) +CFLAGS += $(CCVERBOSE) -NOBJS= $(CRONOBJS) $(ATOBJS) $(ATRMOBJS) $(ATQOBJS) $(CRONTABOBJS) \ +NOBJS= $(CRONOBJS) $(ATOBJS) $(ATRMOBJS1) $(ATQOBJS) $(CRONTABOBJS1) \ $(COMMONOBJS) OBJS = $(NOBJS) $(XPG4COMMONOBJS) $(XPG4ATOBJS) $(XPG4CTOBJS) \ - $(XPG6COMMONOBJS) $(XPG6CTOBJS) + $(XPG6COMMONOBJS) $(XPG6CTOBJS) $(GETRESPOBJ) -SRCS = $(NOBJS:%.o=%.c) +SRCS = $(NOBJS:%.o=%.c) $(GETRESPSRC) CLOBBERFILES += $(SCRIPT) $(XPG4SCRIPT) @@ -151,6 +154,8 @@ lint := LDLIBS += -lproject -lsecdb -lcontract -lpam $(XPG4) := CFLAGS += -DXPG4 $(XPG6) := CFLAGS += -DXPG6 +LINTFLAGS += -u + $(ROOTSVCSYSTEM)/cron.xml := OWNER = root $(ROOTSVCSYSTEM)/cron.xml := GROUP = sys $(ROOTSVCSYSTEM)/cron.xml := FILEMODE = 0444 @@ -179,13 +184,13 @@ $(XPG6) : objs.xpg6 $$(POBJS) $(LINK.c) $(POBJS) -o $@ $(LDLIBS) $(POST_PROCESS) -objs.xpg6/%.o: %.c +objs.xpg6/%.o: %.c $(COMPILE.c) -o $@ $< objs.xpg6: -@mkdir -p $@ -objs.xpg4/%.o: %.c +objs.xpg4/%.o: %.c $(COMPILE.c) -o $@ $< objs.xpg4: @@ -194,6 +199,18 @@ objs.xpg4: objs.xpg4/values-xpg4.o: ../../lib/common/common/values-xpg4.c $(COMPILE.c) -o $@ ../../lib/common/common/values-xpg4.c +%.o: $(SRC)/common/util/%.c + $(COMPILE.c) $(OUTPUT_OPTION) $< + $(POST_PROCESS_O) + +objs.xpg4/%.o: $(SRC)/common/util/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + +objs.xpg6/%.o: $(SRC)/common/util/%.c + $(COMPILE.c) -o $@ $< + $(POST_PROCESS_O) + att1.c : att1.y $(YACC.y) -d att1.y $(MV) y.tab.c att1.c diff --git a/usr/src/cmd/cron/atq.c b/usr/src/cmd/cron/atq.c index 4cedbb518e..37c7db3b58 100644 --- a/usr/src/cmd/cron/atq.c +++ b/usr/src/cmd/cron/atq.c @@ -1,5 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -36,6 +36,8 @@ #include <unistd.h> #include <locale.h> #include <errno.h> +#include <stdlib.h> +#include <string.h> #include "cron.h" extern char *errmsg(); @@ -131,7 +133,7 @@ main(int argc, char **argv) atabortperror("can't allocate list of users"); for (i = 0; i < argc; i++) { if ((chkauthattr(CRONADMIN_AUTH, pr.pw_name)) || - strcmp(pr.pw_name, argv[i]) == 0) { + strcmp(pr.pw_name, argv[i]) == 0) { if ((pp = getpwnam(argv[i])) == NULL) { (void) fprintf(stderr, "atq: No such user %s\n", argv[i]); @@ -204,7 +206,7 @@ main(int argc, char **argv) if (argnum != argc) c = pr.pw_name; else c = *argv; printf("no files for %s.\n", (argnum == 1) ? - c : "specified users"); + c : "specified users"); exit(0); } printqueue(uidlist, argnum); @@ -370,7 +372,6 @@ static void printdate(char *filename) { time_t jobdate; - extern time_t num(); struct tm *unpackeddate; char date[18]; /* reformatted execution date */ @@ -499,7 +500,6 @@ execution(struct dirent **d1, struct dirent **d2) char *name1, *name2; time_t time1, time2; int seq1, seq2; - extern time_t num(); name1 = (*d1)->d_name; name2 = (*d2)->d_name; diff --git a/usr/src/cmd/cron/atrm.c b/usr/src/cmd/cron/atrm.c index 54e2ffc124..f3f2d39bcd 100644 --- a/usr/src/cmd/cron/atrm.c +++ b/usr/src/cmd/cron/atrm.c @@ -1,5 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -33,12 +33,14 @@ #include <unistd.h> #include <locale.h> #include <strings.h> +#include <stdlib.h> +#include <libintl.h> #include "cron.h" +#include "getresponse.h" extern time_t num(); extern char *errmsg(); - -extern void audit_at_delete(char *, char *, int); +extern void audit_at_delete(char *, char *, int); #define SUPERUSER 0 /* is user super-user? */ #define CANTCD "can't change directory to the at directory" @@ -63,6 +65,9 @@ static void atperror2(char *msg, char *name); static void aterror(char *msg); static void powner(char *file); +int getjoblist(struct dirent ***, struct stat ***, int (*)()); +int removentry(char *, struct stat *, uid_t); + int main(int argc, char **argv) { @@ -71,7 +76,6 @@ main(int argc, char **argv) int allflag = 0; /* remove all jobs belonging to user? */ int jobexists; /* does a requested job exist? */ char *pp; - char *getuser(); struct dirent **namelist; /* names of jobs in spooling area */ struct stat **statlist; struct passwd *pwd; @@ -81,6 +85,7 @@ main(int argc, char **argv) * usage info and exit. */ (void) setlocale(LC_ALL, ""); + (void) textdomain(TEXT_DOMAIN); if (argc < 2) usage(); @@ -245,9 +250,14 @@ removentry(char *filename, struct stat *statptr, uid_t user) { struct passwd *pwd; char *pp; - char *getuser(); int r; + if (init_yes() < 0) { + (void) fprintf(stderr, gettext(ERR_MSG_INIT_YES), + strerror(errno)); + exit(1); + } + if (!fflag) printf("%s: ", filename); @@ -266,8 +276,8 @@ removentry(char *filename, struct stat *statptr, uid_t user) powner(filename); printf(") "); } - printf("remove it? "); - if (!yes()) + printf(gettext("remove it? ")); + if (yes() == 0) return (0); } @@ -326,9 +336,7 @@ getjoblist(struct dirent ***namelistp, struct stat ***statlistp, int i; struct stat *statptr; /* pointer to file stat structure */ struct stat **statlist; - extern int alphasort(); /* sort jobs by date of execution */ extern int filewanted(); /* should a file be listed in queue? */ - if (chdir(ATDIR) < 0) atabortperror(CANTCD); @@ -364,26 +372,6 @@ getjoblist(struct dirent ***namelistp, struct stat ***statlistp, return (numjobs); } - -/* - * Get answer to interactive prompts, eating all characters beyond the first - * one. If a 'y' is typed, return 1. - */ -int -yes(void) -{ - int ch; /* dummy variable */ - int ch1; /* dummy variable */ - - ch = ch1 = getchar(); - while (ch1 != '\n' && ch1 != EOF) - ch1 = getchar(); - if (isupper(ch)) - ch = tolower(ch); - return (ch == 'y'); -} - - /* * Get the full login name of a person using his/her user id. */ diff --git a/usr/src/cmd/cron/cron.h b/usr/src/cmd/cron/cron.h index fbd4f666ee..f9b8eacd46 100644 --- a/usr/src/cmd/cron/cron.h +++ b/usr/src/cmd/cron/cron.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -100,6 +99,7 @@ void cron_sendmsg(char, char *, char *, char); time_t num(char **); void *xmalloc(size_t); void *xcalloc(size_t, size_t); +int ascandir(char *, struct dirent *(*[]), int (*)(), int (*)()); #ifdef __cplusplus } diff --git a/usr/src/cmd/cron/cron.xcl b/usr/src/cmd/cron/cron.xcl index facb8a8f0f..118a6403d5 100644 --- a/usr/src/cmd/cron/cron.xcl +++ b/usr/src/cmd/cron/cron.xcl @@ -2,9 +2,8 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -19,10 +18,17 @@ # # CDDL HEADER END # +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +#ident "%Z%%M% %I% %E% SMI" + msgid "" msgid "/etc/cron.d/at.allow" msgid "/etc/cron.d/at.deny" -msgid "cklmsrf:q:t:" +msgid "cklmsrf:p:q:t:" msgid " " msgid "DATEMSK" msgid "%-5d" @@ -81,3 +87,9 @@ msgid "/usr/bin/pwd" msgid "user = %s\t%s\t%s\n" msgid "malloc" msgid "calloc" +msgid "%s/%s%d" +msgid "%1024s" +msgid "%*[^\n]\n" +msgid "cron" +msgid "vi" +msgid "solaris.jobs.admin" diff --git a/usr/src/cmd/cron/crontab.c b/usr/src/cmd/cron/crontab.c index dcf7fe27c5..f079cedf54 100644 --- a/usr/src/cmd/cron/crontab.c +++ b/usr/src/cmd/cron/crontab.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -47,6 +47,7 @@ #include <libintl.h> #include <security/pam_appl.h> #include "cron.h" +#include "getresponse.h" #if defined(XPG4) #define VIPATH "/usr/xpg4/bin/vi" @@ -86,8 +87,8 @@ " editing the crontab data - usually a minor typing error.\n\n" #define BADREAD "error reading your crontab file" #define ED_PROMPT \ - " Edit again, to ensure crontab information is intact (%c/%c)?\n"\ - " ('%c' will discard edits.)" + " Edit again, to ensure crontab information is intact (%s/%s)?\n"\ + " ('%s' will discard edits.)" #define NAMETOOLONG "login name too long" extern int per_errno; @@ -103,15 +104,12 @@ char *tnam; char edtemp[5+13+1]; char line[CTLINESIZE]; static char login[UNAMESIZE]; -static char yeschr; -static char nochr; -static int yes(void); -static int next_field(int, int); -static void catch(int); -static void crabort(char *); -static void cerror(char *); -static void copycron(FILE *); +static int next_field(int, int); +static void catch(int); +static void crabort(char *); +static void cerror(char *); +static void copycron(FILE *); int main(int argc, char **argv) @@ -142,8 +140,12 @@ main(int argc, char **argv) #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ #endif (void) textdomain(TEXT_DOMAIN); - yeschr = *nl_langinfo(YESSTR); - nochr = *nl_langinfo(NOSTR); + + if (init_yes() < 0) { + (void) fprintf(stderr, gettext(ERR_MSG_INIT_YES), + strerror(errno)); + exit(1); + } while ((c = getopt(argc, argv, "elr")) != EOF) switch (c) { @@ -296,23 +298,24 @@ main(int argc, char **argv) } #endif (void) snprintf(buf, sizeof (buf), - "%s %s", editor, edtemp); + "%s %s", editor, edtemp); sleep(1); while (1) { ret = system(buf); /* sanity checks */ if ((tmpfp = fopen(edtemp, "r")) == NULL) - crabort("can't open temporary file"); + crabort("can't open temporary file"); if (fstat(fileno(tmpfp), &stbuf) < 0) - crabort("can't stat temporary file"); + crabort("can't stat temporary file"); if (stbuf.st_size == 0) - crabort("temporary file empty"); + crabort("temporary file empty"); if (omodtime == stbuf.st_mtime) { - (void) unlink(edtemp); - fprintf(stderr, gettext( - "The crontab file was not changed.\n")); - exit(1); + (void) unlink(edtemp); + fprintf(stderr, gettext( + "The crontab file was not" + " changed.\n")); + exit(1); } if ((ret) && (errno != EINTR)) { /* @@ -325,7 +328,7 @@ main(int argc, char **argv) if (isatty(fileno(stdin))) { /* Interactive */ fprintf(stdout, gettext(ED_PROMPT), - yeschr, nochr, nochr); + yesstr, nostr, nostr); fflush(stdout); if (yes()) { @@ -337,9 +340,9 @@ main(int argc, char **argv) exit(1); } } else { - /* Non-interactive, dump changes */ - (void) unlink(edtemp); - exit(1); + /* Non-interactive, dump changes */ + (void) unlink(edtemp); + exit(1); } } exit(0); @@ -547,17 +550,3 @@ char *msg; fprintf(stderr, "crontab: %s\n", gettext(msg)); exit(1); } - -static int -yes(void) -{ - int first_char; - int dummy_char; - - first_char = dummy_char = getchar(); - while ((dummy_char != '\n') && - (dummy_char != '\0') && - (dummy_char != EOF)) - dummy_char = getchar(); - return (first_char == yeschr); -} |