#include "user_list.h"
#include "server_command_list.h"
#include "afs_command_list.h"
+#include "sched.h"
+#include "signal.h"
/** Commands including options must be shorter than this. */
#define MAX_COMMAND_LEN 32768
extern struct misc_meta_data *mmd;
extern struct sender senders[];
-static void dummy(int s)
+static void dummy(__a_unused int s)
{
- /*
- * At least on Solaris, SIGUSR1 is one-shot, i.e. the signal action is
- * restored to the default state once the signal handler has been
- * called.
- */
- if (s == SIGUSR1)
- signal(SIGUSR1, dummy);
}
static void mmd_dup(struct misc_meta_data *new_mmd)
char *status, *flags; /* vss status info */
char *ut = uptime_str();
long offset = (nmmd->offset + 500) / 1000;
- struct timeval now;
+ struct timeval current_time;
struct tm mtime_tm;
/* report real status */
localtime_r(&nmmd->mtime, &mtime_tm);
strftime(mtime, 29, "%b %d %Y", &mtime_tm);
}
- gettimeofday(&now, NULL);
+ gettimeofday(¤t_time, NULL);
ret = make_message(
"%s: %zu\n" /* file size */
"%s: %s\n" /* mtime */
(long unsigned)nmmd->stream_start.tv_sec,
(long unsigned)nmmd->stream_start.tv_usec,
status_item_list[SI_CURRENT_TIME],
- (long unsigned)now.tv_sec,
- (long unsigned)now.tv_usec,
+ (long unsigned)current_time.tv_sec,
+ (long unsigned)current_time.tv_usec,
nmmd->afd.verbose_ls_output
break;
case SENDER_DENY:
case SENDER_ALLOW:
- if (argc != 4 && argc != 5)
+ if (argc != 4 || parse_cidr(argv[3], scd->host,
+ sizeof(scd->host), &scd->netmask) == NULL)
return -E_COMMAND_SYNTAX;
- if (!is_valid_ipv4_address(argv[3]))
- return -E_COMMAND_SYNTAX;
- scd->netmask = 32;
- if (argc == 5) {
- scd->netmask = atoi(argv[4]);
- if (scd->netmask < 0 || scd->netmask > 32)
- return -E_COMMAND_SYNTAX;
- }
- strncpy(scd->host, argv[3], sizeof(scd->host));
break;
case SENDER_ADD:
case SENDER_DELETE:
struct misc_meta_data tmp, *nmmd = &tmp;
char *s;
- signal(SIGUSR1, dummy);
+ para_sigaction(SIGUSR1, dummy);
- if (argc > 1)
- num = atoi(argv[1]);
+ if (argc > 2)
+ return -E_COMMAND_SYNTAX;
+ if (argc > 1) {
+ ret = para_atoi32(argv[1], &num);
+ if (ret < 0)
+ goto out;
+ }
for (;;) {
mmd_dup(nmmd);
}
+static void reset_signals(void)
+{
+ para_sigaction(SIGCHLD, SIG_IGN);
+ para_sigaction(SIGINT, SIG_DFL);
+ para_sigaction(SIGTERM, SIG_DFL);
+ para_sigaction(SIGHUP, SIG_DFL);
+}
+
/**
* Perform user authentication and execute a command.
*
char *p, *command = NULL;
size_t numbytes;
- signal(SIGCHLD, SIG_IGN);
- signal(SIGINT, SIG_DFL);
- signal(SIGTERM, SIG_DFL);
- signal(SIGHUP, SIG_DFL);
-
+ reset_signals();
/* we need a blocking fd here as recv() might return EAGAIN otherwise. */
ret = mark_fd_blocking(fd);
if (ret < 0)