|
@@ -28,17 +28,6 @@
|
|
|
#include <paths.h>
|
|
|
#include <shadow.h>
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
#define TIMEOUT 15
|
|
|
|
|
@@ -56,7 +45,6 @@ static void noop_handler (int __sig);
|
|
|
int
|
|
|
lckpwdf (void)
|
|
|
{
|
|
|
- int flags;
|
|
|
sigset_t saved_set;
|
|
|
struct sigaction saved_act;
|
|
|
sigset_t new_set;
|
|
@@ -72,16 +60,18 @@ lckpwdf (void)
|
|
|
|
|
|
__UCLIBC_MUTEX_LOCK(mylock);
|
|
|
|
|
|
- lock_fd = open (_PATH_PASSWD, O_WRONLY);
|
|
|
+#ifndef O_CLOEXEC
|
|
|
+# define O_CLOEXEC 0
|
|
|
+#endif
|
|
|
+ lock_fd = open (_PATH_PASSWD, O_WRONLY | O_CLOEXEC);
|
|
|
if (lock_fd == -1) {
|
|
|
|
|
|
- goto DONE;
|
|
|
+ goto DONE;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
- flags = fcntl (lock_fd, F_GETFD);
|
|
|
- flags |= FD_CLOEXEC;
|
|
|
- fcntl (lock_fd, F_SETFD, flags);
|
|
|
+ if (O_CLOEXEC == 0)
|
|
|
+ fcntl (lock_fd, F_SETFD, FD_CLOEXEC);
|
|
|
+
|
|
|
|
|
|
process could try this we won't stop when it first fails.
|
|
|
Instead we set a timeout for the system call. Once the timer
|
|
@@ -91,7 +81,7 @@ lckpwdf (void)
|
|
|
|
|
|
It is important that we don't change the signal state. We must
|
|
|
restore the old signal behaviour. */
|
|
|
- memset (&new_act, '\0', sizeof (struct sigaction));
|
|
|
+ memset (&new_act, '\0', sizeof (new_act));
|
|
|
new_act.sa_handler = noop_handler;
|
|
|
__sigfillset (&new_act.sa_mask);
|
|
|
|
|
@@ -125,7 +115,7 @@ lckpwdf (void)
|
|
|
if (result < 0) {
|
|
|
close(lock_fd);
|
|
|
lock_fd = -1;
|
|
|
- goto DONE;
|
|
|
+ goto DONE;
|
|
|
}
|
|
|
rv = 0;
|
|
|
|
|
@@ -146,7 +136,7 @@ ulckpwdf (void)
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- __UCLIBC_MUTEX_LOCK(mylock);
|
|
|
+ __UCLIBC_MUTEX_LOCK(mylock);
|
|
|
|
|
|
result = close (lock_fd);
|
|
|
|
|
@@ -154,7 +144,7 @@ ulckpwdf (void)
|
|
|
lock_fd = -1;
|
|
|
|
|
|
|
|
|
- __UCLIBC_MUTEX_UNLOCK(mylock);
|
|
|
+ __UCLIBC_MUTEX_UNLOCK(mylock);
|
|
|
}
|
|
|
|
|
|
return result;
|