mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00:00
Merge branch 'dev'
Fixes to issues found by Coverity Scan Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+19
-15
No files matched your search
@@ -78,10 +78,9 @@ int sd_notify(int unset_environment, const char *state)
|
|||||||
unsetenv("NOTIFY_SOCKET");
|
unsetenv("NOTIFY_SOCKET");
|
||||||
|
|
||||||
written = write(sd, state, len);
|
written = write(sd, state, len);
|
||||||
if (written != (ssize_t) len) {
|
close(sd);
|
||||||
close(sd);
|
if (written != (ssize_t) len)
|
||||||
return written < 0 ? -errno : -EPROTO;
|
return written < 0 ? -errno : -EPROTO;
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#ifdef HAVE_SYS_SYSMACROS_H
|
#ifdef HAVE_SYS_SYSMACROS_H
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/prctl.h>
|
||||||
#ifdef _LIBITE_LITE
|
#ifdef _LIBITE_LITE
|
||||||
# include <libite/lite.h>
|
# include <libite/lite.h>
|
||||||
#else
|
#else
|
||||||
@@ -626,6 +627,7 @@ int main(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Clear command line arguments for ps display, issue #442
|
* Clear command line arguments for ps display, issue #442
|
||||||
*/
|
*/
|
||||||
|
prctl(PR_SET_NAME, "init", 0, 0, 0);
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
memset(argv[i], 0, strlen(argv[i]));
|
memset(argv[i], 0, strlen(argv[i]));
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -124,7 +124,9 @@ static int parse_level(char **buf, int default_level)
|
|||||||
|
|
||||||
static int do_log(int level, char *msg)
|
static int do_log(int level, char *msg)
|
||||||
{
|
{
|
||||||
syslog(parse_level(&msg, level), "%s", msg);
|
level = parse_level(&msg, level);
|
||||||
|
syslog(level, "%s", msg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +166,7 @@ static int parse_prio(char *arg, int *fac, int *lvl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found == -1)
|
if (found == -1)
|
||||||
return 1;
|
goto notfound;
|
||||||
|
|
||||||
*fac = found;
|
*fac = found;
|
||||||
prio = ptr;
|
prio = ptr;
|
||||||
@@ -179,11 +181,15 @@ static int parse_prio(char *arg, int *fac, int *lvl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == -1)
|
if (found == -1) {
|
||||||
|
notfound:
|
||||||
|
if (duparg)
|
||||||
|
free(duparg);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
*lvl = found;
|
*lvl = found;
|
||||||
|
|
||||||
if (duparg != arg)
|
if (duparg)
|
||||||
free(duparg);
|
free(duparg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+5
-8
@@ -698,8 +698,7 @@ static int service_start(svc_t *svc)
|
|||||||
close(fd);
|
close(fd);
|
||||||
result = -1;
|
result = -1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
} else if (pid > 0) {
|
||||||
if (pid > 1) {
|
|
||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@@ -722,19 +721,19 @@ static int service_start(svc_t *svc)
|
|||||||
}
|
}
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case SVC_NOTIFY_S6:
|
case SVC_NOTIFY_S6:
|
||||||
close(fd); /* client-end of pipefd for s6 notify */
|
if (svc->notify == SVC_NOTIFY_S6)
|
||||||
|
close(fd); /* client-end of pipefd for s6 notify */
|
||||||
|
|
||||||
result = uev_io_init(ctx, &svc->notify_watcher, service_notify_cb, svc, sd, UEV_READ);
|
result = uev_io_init(ctx, &svc->notify_watcher, service_notify_cb, svc, sd, UEV_READ);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
err(1, "%s: failed setting up notify callback", svc_ident(svc, NULL, 0));
|
err(1, "%s: failed setting up notify callback", svc_ident(svc, NULL, 0));
|
||||||
if (svc->notify == SVC_NOTIFY_S6)
|
|
||||||
close(fd);
|
|
||||||
close(sd);
|
close(sd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (pid == 0) {
|
} else { /* pid == 0 */
|
||||||
char str[strlen(NOTIFY_PATH) + 32];
|
char str[strlen(NOTIFY_PATH) + 32];
|
||||||
char *args[MAX_NUM_SVC_ARGS + 1];
|
char *args[MAX_NUM_SVC_ARGS + 1];
|
||||||
int status;
|
int status;
|
||||||
@@ -885,8 +884,6 @@ static int service_start(svc_t *svc)
|
|||||||
syslog(LOG_ERR, "failed starting %s, exit code %d: %s", svc_ident(svc, NULL, 0),
|
syslog(LOG_ERR, "failed starting %s, exit code %d: %s", svc_ident(svc, NULL, 0),
|
||||||
status, strerror(errno));
|
status, strerror(errno));
|
||||||
_exit(status);
|
_exit(status);
|
||||||
} else if (debug) {
|
|
||||||
dbg("Starting PID %d: %s", svc->pid, cmdline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!svc_is_sysv(svc))
|
if (!svc_is_sysv(svc))
|
||||||
|
|||||||
Reference in new issue
Block a user