diff options
| author | dp <none@none> | 2006-02-28 16:15:15 -0800 |
|---|---|---|
| committer | dp <none@none> | 2006-02-28 16:15:15 -0800 |
| commit | 3010f05b8e7c41a103780aa9306659706e47f207 (patch) | |
| tree | bd5f2ef40bd6ee1eaf91c2bd0f0b4d3d849b970b /usr/src/cmd | |
| parent | 7c21cbc95b000a2804a1f0e2a4bedc0be38988b8 (diff) | |
| download | illumos-joyent-3010f05b8e7c41a103780aa9306659706e47f207.tar.gz | |
PSARC 2006/134 logadm(1m) $zonename keyword
4823583 crontab command prints incorrect usage
6352485 RFE: add $zonename to the list of macros supported by logadm
Contributed by Richard Lowe <richlowe@richlowe.net>.
Diffstat (limited to 'usr/src/cmd')
| -rw-r--r-- | usr/src/cmd/cron/crontab.c | 13 | ||||
| -rw-r--r-- | usr/src/cmd/logadm/kw.c | 16 | ||||
| -rw-r--r-- | usr/src/cmd/logadm/logadm.xcl | 10 | ||||
| -rw-r--r-- | usr/src/cmd/logadm/tester | 21 |
4 files changed, 42 insertions, 18 deletions
diff --git a/usr/src/cmd/cron/crontab.c b/usr/src/cmd/cron/crontab.c index 9638fab398..221e084fe8 100644 --- a/usr/src/cmd/cron/crontab.c +++ b/usr/src/cmd/cron/crontab.c @@ -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 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -59,7 +58,11 @@ "because your login shell isn't /usr/bin/sh, you can't use cron." #define WARNSHELL "warning: commands will be executed using /usr/bin/sh\n" #define BADUSAGE \ - "proper usage is: \n crontab [file | -e | -l | -r ] [user]" + "usage:\n" \ + "\tcrontab [file]\n" \ + "\tcrontab -e [username]\n" \ + "\tcrontab -l [username]\n" \ + "\tcrontab -r [username]" #define INVALIDUSER "you are not a valid user (no entry in /etc/passwd)." #define NOTALLOWED "you are not authorized to use cron. Sorry." #define NOTROOT \ diff --git a/usr/src/cmd/logadm/kw.c b/usr/src/cmd/logadm/kw.c index 865fe8ee2b..e6578e130b 100644 --- a/usr/src/cmd/logadm/kw.c +++ b/usr/src/cmd/logadm/kw.c @@ -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 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * logadm/kw.c -- manage keywords table @@ -47,6 +46,7 @@ #include <strings.h> #include <time.h> #include <ctype.h> +#include <zone.h> #include "err.h" #include "lut.h" #include "fn.h" @@ -82,6 +82,8 @@ kw_init(struct fn *fnp, struct fn *nfnp) static char *home; static char *user; static char *logname; + static char zonename[ZONENAME_MAX]; + static zoneid_t zoneid; static int initialized; char *ptr; @@ -153,6 +155,12 @@ kw_init(struct fn *fnp, struct fn *nfnp) if ((logname = getenv("LOGNAME")) != NULL) Keywords = lut_add(Keywords, "logname", STRDUP(logname)); + zoneid = getzoneid(); + if ((getzonenamebyid(zoneid, zonename, sizeof (zonename))) == -1) + err(EF_WARN|EF_SYS, "getzonenamebyid() failed."); + else + Keywords = lut_add(Keywords, "zonename", STRDUP(zonename)); + initialized = 1; } diff --git a/usr/src/cmd/logadm/logadm.xcl b/usr/src/cmd/logadm/logadm.xcl index 933a610850..c0ffe6c18f 100644 --- a/usr/src/cmd/logadm/logadm.xcl +++ b/usr/src/cmd/logadm/logadm.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. @@ -20,8 +19,8 @@ # CDDL HEADER END # # -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" # @@ -159,3 +158,4 @@ msgid "vn" msgid "w" msgid "waitpid" msgid "z" +msgid "zonename" diff --git a/usr/src/cmd/logadm/tester b/usr/src/cmd/logadm/tester index 209af4ee03..1c88ce5bbd 100644 --- a/usr/src/cmd/logadm/tester +++ b/usr/src/cmd/logadm/tester @@ -3,9 +3,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. @@ -21,7 +20,7 @@ # CDDL HEADER END # # -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" @@ -592,6 +591,12 @@ sub kwtest1 { $nodename = `/bin/uname -n`; chomp $nodename; $machine = `/bin/uname -m`; chomp $machine; $release = `/bin/uname -r`; chomp $release; + # /bin/zonename is in SUNWzoneu and so may not be present + if (-f "/bin/zonename") { + $zonename = `/bin/zonename`; chomp $zonename; + } else { + $zonename = "global"; + } $secondblob=<<'EOF'; expand<$file.$n> n -1 hasn 1 result </var/log/syslog\.([0-9]+)$0> expand<$file.$n> n 0 hasn 1 result </var/log/syslog.0> @@ -624,6 +629,7 @@ EOF platform $platform release $release user $ENV{USER} + zonename $zonename $secondblob EOF @@ -657,6 +663,12 @@ sub kwtest2 { $nodename = `/bin/uname -n`; chomp $nodename; $machine = `/bin/uname -m`; chomp $machine; $release = `/bin/uname -r`; chomp $release; + # /bin/zonename is in SUNWzoneu and so may not be present + if (-f "/bin/zonename") { + $zonename = `/bin/zonename`; chomp $zonename; + } else { + $zonename = "global"; + } $secondblob=<<'EOF'; expand<$file.$n> n -1 hasn 1 result </var/log/syslog\.([0-9]+)$0> expand<$file.$n> n 0 hasn 1 result </var/log/syslog.0> @@ -688,6 +700,7 @@ EOF platform $platform release $release user + zonename $zonename $secondblob EOF |
