mirror of
https://github.com/systemd/systemd
synced 2026-03-19 03:24:45 +01:00
Compare commits
No commits in common. "e67ad3e586179c03c969a334a3e2b7d742bd1a94" and "3ae637c42ac316692ce8512b1ad63e4c254e00b1" have entirely different histories.
e67ad3e586
...
3ae637c42a
@ -21,7 +21,6 @@
|
|||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
#include "siphash24.h"
|
#include "siphash24.h"
|
||||||
#include "socket-util.h"
|
#include "socket-util.h"
|
||||||
#include "stat-util.h"
|
|
||||||
#include "stdio-util.h"
|
#include "stdio-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "uid-classification.h"
|
#include "uid-classification.h"
|
||||||
@ -233,23 +232,24 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
|
|||||||
xsprintf(lock_path, "/run/systemd/dynamic-uid/" UID_FMT, candidate);
|
xsprintf(lock_path, "/run/systemd/dynamic-uid/" UID_FMT, candidate);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
lock_fd = open(lock_path, O_CREAT|O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NOCTTY, 0600);
|
lock_fd = open(lock_path, O_CREAT|O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NOCTTY, 0600);
|
||||||
if (lock_fd < 0)
|
if (lock_fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
r = flock(lock_fd, LOCK_EX|LOCK_NB); /* Try to get a BSD file lock on the UID lock file */
|
r = flock(lock_fd, LOCK_EX|LOCK_NB); /* Try to get a BSD file lock on the UID lock file */
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (errno == EAGAIN)
|
if (IN_SET(errno, EBUSY, EAGAIN))
|
||||||
goto next; /* already in use */
|
goto next; /* already in use */
|
||||||
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = fd_verify_linked(lock_fd);
|
if (fstat(lock_fd, &st) < 0)
|
||||||
if (r >= 0)
|
return -errno;
|
||||||
|
if (st.st_nlink > 0)
|
||||||
break;
|
break;
|
||||||
if (r != -EIDRM)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
/* Oh, bummer, we got the lock, but the file was unlinked between the time we opened it and
|
/* Oh, bummer, we got the lock, but the file was unlinked between the time we opened it and
|
||||||
* got the lock. Close it, and try again. */
|
* got the lock. Close it, and try again. */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user