Fix weird flock uses
Change-Id: If8593b8f8d6ef2f91a9ad9c3a0b9f0a02d52444d
This commit is contained in:
parent
6dc59ac7dc
commit
0a4059ee41
@ -443,7 +443,13 @@ md_lock(boolean l)
|
|||||||
|
|
||||||
if (l) {
|
if (l) {
|
||||||
setegid(egid);
|
setegid(egid);
|
||||||
|
#if defined(__minix)
|
||||||
|
/* LSC: Minix flock implementation is a wrapper around fctl, which
|
||||||
|
* requires writeable fds for LOCK_EX to succeed. */
|
||||||
|
if ((fd = open(_PATH_SCOREFILE, O_RDWR)) < 1) {
|
||||||
|
#else
|
||||||
if ((fd = open(_PATH_SCOREFILE, O_RDONLY)) < 1) {
|
if ((fd = open(_PATH_SCOREFILE, O_RDONLY)) < 1) {
|
||||||
|
#endif /* defined(__minix) */
|
||||||
setegid(gid);
|
setegid(gid);
|
||||||
messagef(0, "cannot lock score file");
|
messagef(0, "cannot lock score file");
|
||||||
return;
|
return;
|
||||||
|
@ -381,7 +381,13 @@ creategid(char *group, int gid, const char *name)
|
|||||||
warnx("Can't create group `%s': already exists", group);
|
warnx("Can't create group `%s': already exists", group);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#if defined(__minix)
|
||||||
|
/* LSC: Minix flock implementation is a wrapper around fctl, which
|
||||||
|
* requires writeable fds for LOCK_EX to succeed. */
|
||||||
|
if ((from = fopen(_PATH_GROUP, "r+")) == NULL) {
|
||||||
|
#else
|
||||||
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
||||||
|
#endif /* defined(__minix) */
|
||||||
warn("Can't create group `%s': can't open `%s'", name,
|
warn("Can't create group `%s': can't open `%s'", name,
|
||||||
_PATH_GROUP);
|
_PATH_GROUP);
|
||||||
return 0;
|
return 0;
|
||||||
@ -445,7 +451,13 @@ modify_gid(char *group, char *newent)
|
|||||||
int fd;
|
int fd;
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
|
#if defined(__minix)
|
||||||
|
/* LSC: Minix flock implementation is a wrapper around fctl, which
|
||||||
|
* requires writeable fds for LOCK_EX to succeed. */
|
||||||
|
if ((from = fopen(_PATH_GROUP, "r+")) == NULL) {
|
||||||
|
#else
|
||||||
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
||||||
|
#endif /* defined(__minix) */
|
||||||
warn("Can't modify group `%s': can't open `%s'",
|
warn("Can't modify group `%s': can't open `%s'",
|
||||||
group, _PATH_GROUP);
|
group, _PATH_GROUP);
|
||||||
return 0;
|
return 0;
|
||||||
@ -568,7 +580,13 @@ append_group(char *user, int ngroups, const char **groups)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(__minix)
|
||||||
|
/* LSC: Minix flock implementation is a wrapper around fctl, which
|
||||||
|
* requires writeable fds for LOCK_EX to succeed. */
|
||||||
|
if ((from = fopen(_PATH_GROUP, "r+")) == NULL) {
|
||||||
|
#else
|
||||||
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
||||||
|
#endif /* defined(__minix) */
|
||||||
warn("Can't append group(s) for `%s': can't open `%s'",
|
warn("Can't append group(s) for `%s': can't open `%s'",
|
||||||
user, _PATH_GROUP);
|
user, _PATH_GROUP);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1083,7 +1101,13 @@ adduser(char *login_name, user_t *up)
|
|||||||
login_name, up->u_class);
|
login_name, up->u_class);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__minix)
|
||||||
|
/* LSC: Minix flock implementation is a wrapper around fctl, which
|
||||||
|
* requires writeable fds for LOCK_EX to succeed. */
|
||||||
|
if ((masterfd = open(_PATH_MASTERPASSWD, O_RDWR)) < 0) {
|
||||||
|
#else
|
||||||
if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) < 0) {
|
if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) < 0) {
|
||||||
|
#endif /* defined(__minix) */
|
||||||
err(EXIT_FAILURE, "Can't add user `%s': can't open `%s'",
|
err(EXIT_FAILURE, "Can't add user `%s': can't open `%s'",
|
||||||
login_name, _PATH_MASTERPASSWD);
|
login_name, _PATH_MASTERPASSWD);
|
||||||
}
|
}
|
||||||
@ -1316,7 +1340,13 @@ rm_user_from_groups(char *login_name)
|
|||||||
buf);
|
buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#if defined(__minix)
|
||||||
|
/* LSC: Minix flock implementation is a wrapper around fctl, which
|
||||||
|
* requires writeable fds for LOCK_EX to succeed. */
|
||||||
|
if ((from = fopen(_PATH_GROUP, "r+")) == NULL) {
|
||||||
|
#else
|
||||||
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
if ((from = fopen(_PATH_GROUP, "r")) == NULL) {
|
||||||
|
#endif /* defined(__minix) */
|
||||||
warn("Can't remove user `%s' from `%s': can't open `%s'",
|
warn("Can't remove user `%s' from `%s': can't open `%s'",
|
||||||
login_name, _PATH_GROUP, _PATH_GROUP);
|
login_name, _PATH_GROUP, _PATH_GROUP);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1445,7 +1475,13 @@ moduser(char *login_name, char *newlogin, user_t *up, int allow_samba)
|
|||||||
/* keep dir name in case we need it for '-m' */
|
/* keep dir name in case we need it for '-m' */
|
||||||
homedir = pwp->pw_dir;
|
homedir = pwp->pw_dir;
|
||||||
|
|
||||||
|
#if defined(__minix)
|
||||||
|
/* LSC: Minix flock implementation is a wrapper around fctl, which
|
||||||
|
* requires writeable fds for LOCK_EX to succeed. */
|
||||||
|
if ((masterfd = open(_PATH_MASTERPASSWD, O_RDWR)) < 0) {
|
||||||
|
#else
|
||||||
if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) < 0) {
|
if ((masterfd = open(_PATH_MASTERPASSWD, O_RDONLY)) < 0) {
|
||||||
|
#endif /* defined(__minix) */
|
||||||
err(EXIT_FAILURE, "Can't modify user `%s': can't open `%s'",
|
err(EXIT_FAILURE, "Can't modify user `%s': can't open `%s'",
|
||||||
login_name, _PATH_MASTERPASSWD);
|
login_name, _PATH_MASTERPASSWD);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user