Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl2/lvm2/dist - don't forget to restore the umask ...
details: https://anonhg.NetBSD.org/src/rev/95d4a7cfb1b3
branches: trunk
changeset: 760097:95d4a7cfb1b3
user: christos <christos%NetBSD.org@localhost>
date: Sun Dec 26 14:48:34 2010 +0000
description:
- don't forget to restore the umask on error.
- save and restore umask for control
- chown/chgrp for raw devices
diffstat:
external/gpl2/lvm2/dist/daemons/cmirrord/functions.c | 5 ++++-
external/gpl2/lvm2/dist/libdm/ioctl/libdm-iface.c | 5 ++++-
external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c | 7 +++++--
external/gpl2/lvm2/dist/libdm/libdm-common.c | 14 ++++++++++----
4 files changed, 23 insertions(+), 8 deletions(-)
diffs (120 lines):
diff -r 8037e5b7c29f -r 95d4a7cfb1b3 external/gpl2/lvm2/dist/daemons/cmirrord/functions.c
--- a/external/gpl2/lvm2/dist/daemons/cmirrord/functions.c Sun Dec 26 14:26:45 2010 +0000
+++ b/external/gpl2/lvm2/dist/daemons/cmirrord/functions.c Sun Dec 26 14:48:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: functions.c,v 1.2 2010/12/23 17:46:54 christos Exp $ */
+/* $NetBSD: functions.c,v 1.3 2010/12/26 14:48:34 christos Exp $ */
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
@@ -303,6 +303,7 @@
struct dirent *dep;
struct stat statbuf;
int major, minor;
+ mode_t old_umask;
if (!strstr(major_minor_str, ":")) {
r = stat(major_minor_str, &statbuf);
@@ -350,7 +351,9 @@
LOG_DBG("Path not found for %d/%d", major, minor);
LOG_DBG("Creating /dev/mapper/%d-%d", major, minor);
sprintf(path_rtn, "/dev/mapper/%d-%d", major, minor);
+ old_umask = umask(0);
r = mknod(path_rtn, S_IFBLK | DM_DEVICE_MODE, MKDEV(major, minor));
+ umask(old_umask);
if (r != -1)
r = chown(path_rtn, DM_DEVICE_UID, DM_DEVICE_GID);
diff -r 8037e5b7c29f -r 95d4a7cfb1b3 external/gpl2/lvm2/dist/libdm/ioctl/libdm-iface.c
--- a/external/gpl2/lvm2/dist/libdm/ioctl/libdm-iface.c Sun Dec 26 14:26:45 2010 +0000
+++ b/external/gpl2/lvm2/dist/libdm/ioctl/libdm-iface.c Sun Dec 26 14:48:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libdm-iface.c,v 1.2 2010/12/23 17:46:54 christos Exp $ */
+/* $NetBSD: libdm-iface.c,v 1.3 2010/12/26 14:48:34 christos Exp $ */
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
@@ -245,11 +245,14 @@
log_verbose("Creating device %s (%u, %u)", control, major, minor);
+ old_umask = umask(0);
if (mknod(control, S_IFCHR | DM_DEVICE_MODE,
MKDEV(major, minor)) < 0) {
+ umask(old_umask);
log_sys_error("mknod", control);
return 0;
}
+ umask(old_umask);
if (chown(control, DM_DEVICE_UID, DM_DEVICE_GID) == -1) {
log_sys_error("cbown", control);
return 0;
diff -r 8037e5b7c29f -r 95d4a7cfb1b3 external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c
--- a/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c Sun Dec 26 14:26:45 2010 +0000
+++ b/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c Sun Dec 26 14:48:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libdm-nbsd-iface.c,v 1.8 2010/12/23 17:46:54 christos Exp $ */
+/* $NetBSD: libdm-nbsd-iface.c,v 1.9 2010/12/26 14:48:34 christos Exp $ */
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
@@ -153,7 +153,7 @@
if (!major)
return 0;
- old_umask = umask(0022);
+ old_umask = umask(DM_DEV_DIR_UMASK);
ret = dm_create_dir(dm_dir());
umask(old_umask);
@@ -162,11 +162,14 @@
log_verbose("Creating device %s (%u, %u)", control, major, minor);
+ old_umask = umask(0);
if (mknod(control, S_IFCHR | DM_DEVICE_MODE,
MKDEV(major, minor)) < 0) {
+ umask(old_umask);
log_sys_error("mknod", control);
return 0;
}
+ umask(old_umask);
if (chown(control, DM_DEVICE_UID, DM_DEVICE_GID) == -1) {
log_sys_error("chown", control);
return 0;
diff -r 8037e5b7c29f -r 95d4a7cfb1b3 external/gpl2/lvm2/dist/libdm/libdm-common.c
--- a/external/gpl2/lvm2/dist/libdm/libdm-common.c Sun Dec 26 14:26:45 2010 +0000
+++ b/external/gpl2/lvm2/dist/libdm/libdm-common.c Sun Dec 26 14:48:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libdm-common.c,v 1.5 2009/12/05 11:42:24 haad Exp $ */
+/* $NetBSD: libdm-common.c,v 1.6 2010/12/26 14:48:34 christos Exp $ */
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
@@ -450,9 +450,15 @@
}
old_mask = umask(0);
+ if (mknod(rpath, S_IFCHR | mode, rdev) < 0) {
+ umask(old_mask);
+ log_error("Unable to make device node for '%s'", raw_devname);
+ return 0;
+ }
+ umask(old_mask);
- if (mknod(rpath, S_IFCHR | mode, rdev) < 0) {
- log_error("Unable to make device node for '%s'", raw_devname);
+ if (chown(path, uid, gid) < 0) {
+ log_sys_error("chown", rpath);
return 0;
}
#endif
@@ -505,7 +511,7 @@
char path[PATH_MAX];
struct stat info;
- #ifdef __NetBSD__
+#ifdef __NetBSD__
char rpath[PATH_MAX];
char raw_devname[DM_NAME_LEN+1]; /* r + other device name */
Home |
Main Index |
Thread Index |
Old Index