blob: f96ab532b5b2a9cefd632e4c4a36ed903327a072 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*
* Copyright (c) 2010 Wind River Systems; see
* guts/COPYRIGHT for information.
*
* SPDX-License-Identifier: LGPL-2.1-only
*
* static int
* wrap_lckpwdf(void) {
* int rc = -1;
*/
rc = pseudo_pwd_lck_open();
if (rc != -1) {
struct flock lck = {
.l_type = F_RDLCK,
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 1
};
/* I don't really care whether this works. */
fcntl(rc, F_SETFD, FD_CLOEXEC);
/* Now lock it. */
alarm(15); /* magic number from man page */
rc = fcntl(rc, F_SETLKW, &lck);
alarm(0);
if (rc == -1) {
int save_errno = errno;
pseudo_pwd_lck_close();
errno = save_errno;
}
}
/* return rc;
* }
*/
|