- don't forget to restore the umask on error.
- save and restore umask for control - chown/chgrp for raw devices
This commit is contained in:
parent
8d68ab3ee4
commit
017d3467b1
@ -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 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
|
||||
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 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
|
||||
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);
|
||||
|
@ -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 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
|
||||
|
||||
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;
|
||||
|
@ -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 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
|
||||
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 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
|
||||
|
||||
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;
|
||||
|
12
external/gpl2/lvm2/dist/libdm/libdm-common.c
vendored
12
external/gpl2/lvm2/dist/libdm/libdm-common.c
vendored
@ -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,11 +450,17 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
|
||||
}
|
||||
|
||||
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 (chown(path, uid, gid) < 0) {
|
||||
log_sys_error("chown", rpath);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
_build_dev_path(path, sizeof(path), dev_name);
|
||||
@ -505,7 +511,7 @@ static int _rm_dev_node(const char *dev_name, int check_udev)
|
||||
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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user