mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-06 17:18:29 +03:00
lvmetad: Only create pidfile when running as a daemon (no -f).
Additionally, -f now makes -s mandatory, so the foreground (debugging) lvmetad does not steal the system-wide socket accidentally.
This commit is contained in:
parent
329d10268c
commit
1997149263
@ -1060,6 +1060,7 @@ int main(int argc, char *argv[])
|
||||
daemon_state s = { .private = NULL };
|
||||
lvmetad_state ls;
|
||||
int _restart = 0;
|
||||
int _socket_override = 1;
|
||||
|
||||
s.name = "lvmetad";
|
||||
s.private = &ls;
|
||||
@ -1067,8 +1068,10 @@ int main(int argc, char *argv[])
|
||||
s.daemon_fini = fini;
|
||||
s.handler = handler;
|
||||
s.socket_path = getenv("LVM_LVMETAD_SOCKET");
|
||||
if (!s.socket_path)
|
||||
if (!s.socket_path) {
|
||||
_socket_override = 0;
|
||||
s.socket_path = DEFAULT_RUN_DIR "/lvmetad.socket";
|
||||
}
|
||||
s.pidfile = LVMETAD_PIDFILE;
|
||||
s.protocol = "lvmetad";
|
||||
s.protocol_version = 1;
|
||||
@ -1094,6 +1097,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case 's': // --socket
|
||||
s.socket_path = optarg;
|
||||
_socket_override = 1;
|
||||
break;
|
||||
case 'V':
|
||||
printf("lvmetad version 0\n");
|
||||
@ -1101,6 +1105,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (s.foreground && !_socket_override) {
|
||||
fprintf(stderr, "A socket path (-s) is required in foreground mode.");
|
||||
exit(2);
|
||||
} else {
|
||||
s.pidfile = NULL;
|
||||
}
|
||||
|
||||
daemon_start(s);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user