From 10ddde3aee60d88fa580028fcf7642a87e80a2c6 Mon Sep 17 00:00:00 2001 From: aj Date: Thu, 21 Jun 2007 10:39:47 -0700 Subject: 6535551 TX DA GUI behaves incorrectly if multiple rapid updates to TX DA database are done 6542809 TX: add_allocatable/remove_allocatable don't play well with other instances of themselves 6545689 device_clean scripts should be able to return a "CANCEL" return code 6549055 TX: deallocate(1), list_devices(1) should allow operation on classes of devices --- usr/src/lib/libbsm/common/devalloc.c | 45 +++++++++++++++++++++++++----------- usr/src/lib/libbsm/common/devalloc.h | 11 ++++----- usr/src/lib/libbsm/common/devices.h | 11 +++++---- 3 files changed, 42 insertions(+), 25 deletions(-) (limited to 'usr/src/lib/libbsm/common') diff --git a/usr/src/lib/libbsm/common/devalloc.c b/usr/src/lib/libbsm/common/devalloc.c index 08db0f0325..e39b57fa23 100644 --- a/usr/src/lib/libbsm/common/devalloc.c +++ b/usr/src/lib/libbsm/common/devalloc.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -849,6 +849,11 @@ int _da_lock_devdb(char *rootdir) { int lockfd = -1; + int ret; + int count = 0; + int retry = 10; + int retry_sleep; + uint_t seed; char *lockfile; char path[MAXPATHLEN]; int size = sizeof (path); @@ -873,14 +878,27 @@ _da_lock_devdb(char *rootdir) (void) close(lockfd); return (-1); } - if (lockf(lockfd, F_TLOCK, 0) == -1) { - /* cannot set lock */ - (void) close(lockfd); - return (-1); + errno = 0; + while (retry > 0) { + count++; + seed = (uint_t)gethrtime(); + ret = lockf(lockfd, F_TLOCK, 0); + if (ret == 0) { + (void) utime(lockfile, NULL); + return (lockfd); + } + if ((errno != EACCES) && (errno != EAGAIN)) { + /* cannot set lock */ + (void) close(lockfd); + return (-1); + } + retry--; + retry_sleep = rand_r(&seed)/((RAND_MAX + 2)/3) + count; + (void) sleep(retry_sleep); + errno = 0; } - (void) utime(lockfile, NULL); - return (lockfd); + return (-1); } /* @@ -1160,10 +1178,10 @@ da_update_device(da_args *dargs) int tafd = -1, tmfd = -1; int lockfd = -1; char *rootdir = NULL; - char *apathp = NULL, *mpathp = NULL, *dapathp = NULL, - *dmpathp = NULL; - char apath[MAXPATHLEN], mpath[MAXPATHLEN], - dapath[MAXPATHLEN], dmpath[MAXPATHLEN]; + char *apathp = NULL, *mpathp = NULL; + char *dapathp = NULL, *dmpathp = NULL; + char apath[MAXPATHLEN], mpath[MAXPATHLEN]; + char dapath[MAXPATHLEN], dmpath[MAXPATHLEN]; FILE *tafp = NULL, *tmfp = NULL, *dafp = NULL; struct stat dastat; devinfo_t *devinfo; @@ -1620,12 +1638,11 @@ da_remove_list(devlist_t *dlist, char *link, int type, char *devname, int size) if (plen == 0) { slen = snprintf(current->devinfo.devlist, - nlen, "%s", lname); + nlen, "%s", lname); } else { slen = snprintf(current->devinfo.devlist + - plen, nlen - plen, " %s", - lname); + plen, nlen - plen, " %s", lname); } plen = plen + slen + 1; } diff --git a/usr/src/lib/libbsm/common/devalloc.h b/usr/src/lib/libbsm/common/devalloc.h index 7952a302f5..12ec8732d2 100644 --- a/usr/src/lib/libbsm/common/devalloc.h +++ b/usr/src/lib/libbsm/common/devalloc.h @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -44,6 +44,9 @@ extern "C" { #define DA_UID (uid_t)0 /* root */ #define DA_GID (gid_t)3 /* sys */ +#define ALLOC_MODE 0600 +#define DEALLOC_MODE 0000 + #define LOGINDEVPERM "/etc/logindevperm" #define DA_DB_LOCK "/etc/security/.da_db_lock" #define DA_DEV_LOCK "/etc/security/.da_dev_lock" @@ -79,12 +82,6 @@ extern "C" { #define DA_ANYUSER "*" #define DA_NOUSER "@" -#define ALLOC_UID (uid_t)0 /* root */ -#define ALLOC_GID (gid_t)3 /* sys */ -#define ALLOC_ERRID (uid_t)2 /* bin */ -#define ALLOC_MODE 0600 -#define DEALLOC_MODE 0000 - #define DA_SILENT 0x00000001 #define DA_VERBOSE 0x00000002 #define DA_ADD 0x00000004 diff --git a/usr/src/lib/libbsm/common/devices.h b/usr/src/lib/libbsm/common/devices.h index 04a3edceea..7b413eaca8 100644 --- a/usr/src/lib/libbsm/common/devices.h +++ b/usr/src/lib/libbsm/common/devices.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -35,17 +35,20 @@ extern "C" { #include #include -/* - * These are unsupported, SUN-private interfaces. - */ #define DAOPT_AUTHS "auths" +#define DAOPT_CLASS "class" #define DAOPT_CSCRIPT "cleanscript" #define DAOPT_MINLABEL "minlabel" #define DAOPT_MAXLABEL "maxlabel" +#define DAOPT_XDISPLAY "xdpy" #define DAOPT_ZONE "zone" #define DA_RESERVED "reserved" +/* + * These are unsupported, SUN-private interfaces. + */ + typedef struct { char *da_devname; char *da_devtype; -- cgit v1.2.3