projects
/
darkstat-debian
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use the host compiler for build tool c-ify.
[darkstat-debian]
/
pidfile.c
diff --git
a/pidfile.c
b/pidfile.c
index
044c574
..
92403cd
100644
(file)
--- a/
pidfile.c
+++ b/
pidfile.c
@@
-1,5
+1,5
@@
/* darkstat 3
/* darkstat 3
- * copyright (c) 2007-201
1
Emil Mikulic.
+ * copyright (c) 2007-201
4
Emil Mikulic.
*
* pidfile.h: pidfile manglement
*
*
* pidfile.h: pidfile manglement
*
@@
-29,10
+29,9
@@
static int pidfd = -1;
static const char *pidname = NULL;
static int pidfd = -1;
static const char *pidname = NULL;
-void
-pidfile_create(const char *chroot_dir, const char *filename,
- const char *privdrop_user)
-{
+void pidfile_create(const char *chroot_dir,
+ const char *filename,
+ const char *privdrop_user) {
struct passwd *pw;
if (pidfd != -1)
struct passwd *pw;
if (pidfd != -1)
@@
-48,8
+47,11
@@
pidfile_create(const char *chroot_dir, const char *filename,
err(1, "getpwnam(\"%s\") failed", privdrop_user);
}
err(1, "getpwnam(\"%s\") failed", privdrop_user);
}
- if (chdir(chroot_dir) == -1)
- err(1, "chdir(\"%s\") failed", chroot_dir);
+ if (chroot_dir != NULL) {
+ if (chdir(chroot_dir) == -1) {
+ err(1, "chdir(\"%s\") failed", chroot_dir);
+ }
+ }
pidname = filename;
pidfd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
if (pidfd == -1)
pidname = filename;
pidfd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
if (pidfd == -1)