|
Packit |
081926 |
/*
|
|
Packit |
081926 |
* panic.c - terminate fast in case of error
|
|
Packit |
081926 |
* Copyright (C) 1993 Thomas Koenig
|
|
Packit |
081926 |
*
|
|
Packit |
081926 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
081926 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
081926 |
* the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
081926 |
* (at your option) any later version.
|
|
Packit |
081926 |
*
|
|
Packit |
081926 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
081926 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
081926 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
081926 |
* GNU General Public License for more details.
|
|
Packit |
081926 |
*
|
|
Packit |
081926 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
081926 |
* along with this program; if not, write to the Free Software
|
|
Packit |
081926 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
081926 |
*/
|
|
Packit |
081926 |
|
|
Packit |
081926 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
081926 |
#include "config.h"
|
|
Packit |
081926 |
#endif
|
|
Packit |
081926 |
|
|
Packit |
081926 |
/* System Headers */
|
|
Packit |
081926 |
|
|
Packit |
081926 |
#ifdef HAVE_ERRNO_H
|
|
Packit |
081926 |
#include <errno.h>
|
|
Packit |
081926 |
#endif
|
|
Packit |
081926 |
|
|
Packit |
081926 |
#include <stdio.h>
|
|
Packit |
081926 |
#include <stdlib.h>
|
|
Packit |
081926 |
|
|
Packit |
081926 |
#ifdef HAVE_UNISTD_H
|
|
Packit |
081926 |
#include <unistd.h>
|
|
Packit |
081926 |
#endif
|
|
Packit |
081926 |
|
|
Packit |
081926 |
#ifdef HAVE_STDARG_H
|
|
Packit |
081926 |
#include <stdarg.h>
|
|
Packit |
081926 |
#endif
|
|
Packit |
081926 |
|
|
Packit |
081926 |
/* Local headers */
|
|
Packit |
081926 |
|
|
Packit |
081926 |
#include "panic.h"
|
|
Packit |
081926 |
#include "privs.h"
|
|
Packit |
081926 |
#include "at.h"
|
|
Packit |
081926 |
|
|
Packit |
081926 |
/* File scope variables */
|
|
Packit |
081926 |
|
|
Packit |
081926 |
/* External variables */
|
|
Packit |
081926 |
|
|
Packit |
081926 |
/* Global functions */
|
|
Packit |
081926 |
|
|
Packit |
081926 |
void
|
|
Packit |
081926 |
panic(char *a)
|
|
Packit |
081926 |
{
|
|
Packit |
081926 |
/* Something fatal has happened, print error message and exit.
|
|
Packit |
081926 |
*/
|
|
Packit |
081926 |
fprintf(stderr, "%s: %s\n", namep, a);
|
|
Packit |
081926 |
if (fcreated) {
|
|
Packit |
081926 |
setregid(real_gid, effective_gid);
|
|
Packit |
081926 |
unlink(atfile);
|
|
Packit |
081926 |
setregid(effective_gid, real_gid);
|
|
Packit |
081926 |
}
|
|
Packit |
081926 |
|
|
Packit |
081926 |
exit(EXIT_FAILURE);
|
|
Packit |
081926 |
}
|
|
Packit |
081926 |
|
|
Packit |
081926 |
void
|
|
Packit |
081926 |
perr(const char *fmt,...)
|
|
Packit |
081926 |
{
|
|
Packit |
081926 |
/* Some operating system error; print error message and exit.
|
|
Packit |
081926 |
*/
|
|
Packit |
081926 |
char buf[1024];
|
|
Packit |
081926 |
va_list args;
|
|
Packit |
081926 |
|
|
Packit |
081926 |
va_start(args, fmt);
|
|
Packit |
081926 |
vsnprintf(buf, sizeof(buf), fmt, args);
|
|
Packit |
081926 |
va_end(args);
|
|
Packit |
081926 |
|
|
Packit |
081926 |
perror(buf);
|
|
Packit |
081926 |
if (fcreated) {
|
|
Packit |
081926 |
setregid(real_gid, effective_gid);
|
|
Packit |
081926 |
unlink(atfile);
|
|
Packit |
081926 |
setregid(effective_gid, real_gid);
|
|
Packit |
081926 |
}
|
|
Packit |
081926 |
|
|
Packit |
081926 |
exit(EXIT_FAILURE);
|
|
Packit |
081926 |
}
|
|
Packit |
081926 |
|
|
Packit |
081926 |
void
|
|
Packit |
081926 |
usage(void)
|
|
Packit |
081926 |
{
|
|
Packit |
081926 |
/* Print usage and exit.
|
|
Packit |
081926 |
*/
|
|
Packit |
081926 |
fprintf(stderr, "Usage: at [-V] [-q x] [-f file] [-mMlbv] timespec ...\n"
|
|
Packit |
081926 |
" at [-V] [-q x] [-f file] [-mMlbv] -t time\n"
|
|
Packit |
081926 |
" at -c job ...\n"
|
|
Packit |
081926 |
" atq [-V] [-q x]\n"
|
|
Packit |
081926 |
" at [ -rd ] job ...\n"
|
|
Packit |
081926 |
" atrm [-V] job ...\n"
|
|
Packit |
081926 |
" batch\n");
|
|
Packit |
081926 |
exit(EXIT_FAILURE);
|
|
Packit |
081926 |
}
|