version 1.68, 2015/11/04 20:28:17 |
version 1.69, 2015/11/06 23:47:42 |
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
*/ |
|
|
#define MAIN_PROGRAM |
|
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
|
|
|
|
static __dead void |
static __dead void |
panic(const char *a) |
panic(const char *a) |
{ |
{ |
(void)fprintf(stderr, "%s: %s\n", ProgramName, a); |
(void)fprintf(stderr, "%s: %s\n", __progname, a); |
if (fcreated) |
if (fcreated) |
unlink(atfile); |
unlink(atfile); |
|
|
|
|
static __dead void |
static __dead void |
panic2(const char *a, const char *b) |
panic2(const char *a, const char *b) |
{ |
{ |
(void)fprintf(stderr, "%s: %s%s\n", ProgramName, a, b); |
(void)fprintf(stderr, "%s: %s%s\n", __progname, a, b); |
if (fcreated) |
if (fcreated) |
unlink(atfile); |
unlink(atfile); |
|
|
|
|
} else |
} else |
uids = NULL; |
uids = NULL; |
|
|
shortformat = strcmp(ProgramName, "at") == 0; |
shortformat = strcmp(__progname, "at") == 0; |
|
|
if (chdir(AT_DIR) != 0) |
if (chdir(AT_DIR) != 0) |
perr2("Cannot change to ", AT_DIR); |
perr2("Cannot change to ", AT_DIR); |
|
|
if (user_uid != pw->pw_uid && user_uid != 0) { |
if (user_uid != pw->pw_uid && user_uid != 0) { |
fprintf(stderr, "%s: Only the superuser" |
fprintf(stderr, "%s: Only the superuser" |
" may %s other users' jobs\n", |
" may %s other users' jobs\n", |
ProgramName, what == ATRM |
__progname, what == ATRM |
? "remove" : "view"); |
? "remove" : "view"); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
if (jobs[i] != NULL) { |
if (jobs[i] != NULL) { |
if (!force) |
if (!force) |
fprintf(stderr, "%s: %s: no such job\n", |
fprintf(stderr, "%s: %s: no such job\n", |
ProgramName, jobs[i]); |
__progname, jobs[i]); |
error++; |
error++; |
} |
} |
} |
} |
|
|
if (argc < 1) |
if (argc < 1) |
usage(); |
usage(); |
|
|
if ((ProgramName = strrchr(argv[0], '/')) != NULL) |
|
ProgramName++; |
|
else |
|
ProgramName = argv[0]; |
|
|
|
user_uid = getuid(); |
user_uid = getuid(); |
user_gid = getgid(); |
user_gid = getgid(); |
spool_gid = getegid(); |
spool_gid = getegid(); |
|
|
/* find out what this program is supposed to do */ |
/* find out what this program is supposed to do */ |
if (strcmp(ProgramName, "atq") == 0) { |
if (strcmp(__progname, "atq") == 0) { |
program = ATQ; |
program = ATQ; |
options = "cnvq:"; |
options = "cnvq:"; |
} else if (strcmp(ProgramName, "atrm") == 0) { |
} else if (strcmp(__progname, "atrm") == 0) { |
program = ATRM; |
program = ATRM; |
options = "afi"; |
options = "afi"; |
} else if (strcmp(ProgramName, "batch") == 0) { |
} else if (strcmp(__progname, "batch") == 0) { |
program = BATCH; |
program = BATCH; |
options = "f:q:mv"; |
options = "f:q:mv"; |
} |
} |