static int do_log_refclocks = 0;
static int do_log_tempcomp = 0;
static int log_banner = 32;
-static char *logdir;
-static char *dumpdir;
+static char *logdir = NULL;
+static char *dumpdir = NULL;
static int enable_local=0;
static int local_stratum;
static IPAddr bind_cmd_address4, bind_cmd_address6;
/* Path to the Unix domain command socket. */
-static char *bind_cmd_path;
+static char *bind_cmd_path = NULL;
/* Path to Samba (ntp_signd) socket. */
static char *ntp_signd_socket = NULL;
/* Filename to use for storing pid of running chronyd, to prevent multiple
* chronyds being started. */
-static char *pidfile;
+static char *pidfile = NULL;
/* Rate limiting parameters */
static int ntp_ratelimit_enabled = 0;
ntp_restrictions = ARR_CreateInstance(sizeof (AllowDeny));
cmd_restrictions = ARR_CreateInstance(sizeof (AllowDeny));
- dumpdir = Strdup("");
- logdir = Strdup("");
rtc_device = Strdup(DEFAULT_RTC_DEVICE);
hwclock_file = Strdup(DEFAULT_HWCLOCK_FILE);
user = Strdup(DEFAULT_USER);
if (client_only) {
cmd_port = ntp_port = 0;
- bind_cmd_path = Strdup("");
- pidfile = Strdup("");
} else {
bind_cmd_path = Strdup(DEFAULT_COMMAND_SOCKET);
pidfile = Strdup(DEFAULT_PID_FILE);
if (line[0] == '/') {
parse_string(line, &bind_cmd_path);
/* / disables the socket */
- if (!strcmp(bind_cmd_path, "/"))
- bind_cmd_path[0] = '\0';
+ if (strcmp(bind_cmd_path, "/") == 0) {
+ Free(bind_cmd_path);
+ bind_cmd_path = NULL;
+ }
} else if (UTI_StringToIP(line, &ip)) {
if (ip.family == IPADDR_INET4)
bind_cmd_address4 = ip;
char *dir;
/* Create a directory for the Unix domain command socket */
- if (bind_cmd_path[0]) {
+ if (bind_cmd_path) {
dir = UTI_PathToDir(bind_cmd_path);
UTI_CreateDirAndParents(dir, 0770, uid, gid);
domain sockets are ignored on some systems (e.g. Solaris). */
if (!UTI_CheckDirPermissions(dir, 0770, uid, gid)) {
LOG(LOGS_WARN, "Disabled command socket %s", bind_cmd_path);
- bind_cmd_path[0] = '\0';
+ Free(bind_cmd_path);
+ bind_cmd_path = NULL;
}
Free(dir);
}
- if (logdir[0])
+ if (logdir)
UTI_CreateDirAndParents(logdir, 0755, uid, gid);
- if (dumpdir[0])
+ if (dumpdir)
UTI_CreateDirAndParents(dumpdir, 0755, uid, gid);
}
{
const char *pidfile = CNF_GetPidFile();
- if (!pidfile[0])
+ if (!pidfile)
return;
if (!UTI_RemoveFile(NULL, pidfile, NULL))
{
if (!initialised) exit(exit_status);
- if (CNF_GetDumpDir()[0] != '\0') {
- SRC_DumpSources();
- }
+ SRC_DumpSources();
/* Don't update clock when removing sources */
REF_SetMode(REF_ModeIgnore);
FILE *in;
int pid, count;
- if (!pidfile[0])
+ if (!pidfile)
return;
in = UTI_OpenFile(NULL, pidfile, NULL, 'r', 0);
const char *pidfile = CNF_GetPidFile();
FILE *out;
- if (!pidfile[0])
+ if (!pidfile)
return;
out = UTI_OpenFile(NULL, pidfile, NULL, 'W', 0644);
char filename[64], *dumpdir;
dumpdir = CNF_GetDumpDir();
- if (dumpdir[0] == '\0') {
+ if (!dumpdir)
return NULL;
- }
/* Include IP address in the name for NTP sources, or reference ID in hex */
if (inst->type == SRC_NTP && UTI_IsIPReal(inst->ip_addr))
size_t i;
dumpdir = CNF_GetDumpDir();
- if (dumpdir[0] == '\0' ||
+ if (!dumpdir ||
snprintf(pattern, sizeof (pattern), "%s/*.dat", dumpdir) >= sizeof (pattern))
return;