4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2011 Gary Mills
24 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
27 #define _POSIX_PTHREAD_SEMANTICS /* for getgrnam_r */
29 #define _REENTRANT /* for strtok_r */
41 #include <nss_dbdefs.h>
45 #include <sys/types.h>
48 #include <sys/sunddi.h>
49 #include <sys/devinfo_impl.h>
50 #include <sys/hwconf.h>
51 #include <sys/modctl.h>
52 #include <libnvpair.h>
53 #include <device_info.h>
56 #include <libdevinfo.h>
61 extern int is_minor_node(const char *, const char **);
63 static int is_login_user(uid_t
);
64 static int logindevperm(const char *, uid_t
, gid_t
, void (*)());
65 static int dir_dev_acc(char *, char *, uid_t
, gid_t
, mode_t
, char *line
,
67 static int setdevaccess(char *, uid_t
, gid_t
, mode_t
, void (*)());
68 static void logerror(char *);
70 static int is_blank(char *);
72 #define MAX_LINELEN 256
73 #define LOGINDEVPERM "/etc/logindevperm"
74 #define DIRWILD "/*" /* directory wildcard */
75 #define DIRWLDLEN 2 /* strlen(DIRWILD) */
78 * Revoke all access to a device node and make sure that there are
79 * no interposed streams devices attached. Must be called before a
80 * device is actually opened.
81 * When fdetach is called, the underlying device node is revealed; it
82 * will have the previous owner and that owner can re-attach; so we
84 * Ignore non-existent devices.
87 setdevaccess(char *dev
, uid_t uid
, gid_t gid
, mode_t mode
,
88 void (*errmsg
)(char *))
90 int err
= 0, local_errno
;
91 char errstring
[MAX_LINELEN
];
94 if (chown(dev
, uid
, gid
) == -1) {
95 if (errno
== ENOENT
) /* no such file */
102 * don't fdetach block devices, as it will unmount them
104 if (!((stat(dev
, &st
) == 0) && ((st
.st_mode
& S_IFMT
) == S_IFBLK
))) {
105 while (fdetach(dev
) == 0) {
106 if (chown(dev
, uid
, gid
) == -1) {
112 (void) snprintf(errstring
, MAX_LINELEN
,
113 "failed to chown device %s: %s\n",
114 dev
, strerror(local_errno
));
115 (*errmsg
)(errstring
);
120 * strip_acl sets an acl and changes the files owner/group
122 err
= acl_strip(dev
, uid
, gid
, mode
);
126 * If the file system returned ENOSYS, we know that it
127 * doesn't support ACLs, therefore, we must assume that
128 * there were no ACLs to remove in the first place.
131 if (errno
!= ENOSYS
) {
135 (void) snprintf(errstring
, MAX_LINELEN
,
136 "failed to set acl on device %s: %s\n",
137 dev
, strerror(errno
));
138 (*errmsg
)(errstring
);
141 if (chmod(dev
, mode
) == -1) {
144 (void) snprintf(errstring
, MAX_LINELEN
,
145 "failed to chmod device %s: %s\n",
146 dev
, strerror(errno
));
147 (*errmsg
)(errstring
);
156 * logindevperm - change owner/group/permissions of devices
157 * list in /etc/logindevperm.
160 logindevperm(const char *ttyn
, uid_t uid
, gid_t gid
, void (*errmsg
)(char *))
162 int err
= 0, lineno
= 0;
163 const char *field_delims
= " \t\n";
164 char line
[MAX_LINELEN
], errstring
[MAX_LINELEN
];
165 char saveline
[MAX_LINELEN
];
173 char ttyn_path
[PATH_MAX
+ 1];
176 if ((fp
= fopen(LOGINDEVPERM
, "r")) == NULL
) {
178 (void) snprintf(errstring
, MAX_LINELEN
,
179 LOGINDEVPERM
": open failed: %s\n",
181 (*errmsg
)(errstring
);
186 if ((n
= resolvepath(ttyn
, ttyn_path
, PATH_MAX
)) == -1)
190 while (fgets(line
, MAX_LINELEN
, fp
) != NULL
) {
192 char tmp
[PATH_MAX
+ 1];
196 if ((ptr
= strchr(line
, '#')) != NULL
)
197 *ptr
= '\0'; /* handle comments */
199 (void) strcpy(saveline
, line
);
201 console
= strtok_r(line
, field_delims
, &last
);
203 continue; /* ignore blank lines */
205 if ((n
= resolvepath(console
, tmp
, PATH_MAX
)) == -1)
209 if (strcmp(ttyn_path
, tmp
) != 0)
212 mode_str
= strtok_r(last
, field_delims
, &last
);
213 if (mode_str
== NULL
) {
214 err
= -1; /* invalid entry, skip */
216 (void) snprintf(errstring
, MAX_LINELEN
,
218 ": line %d, invalid entry -- %s\n",
220 (*errmsg
)(errstring
);
225 /* convert string to octal value */
226 mode
= strtol(mode_str
, &ptr
, 8);
227 if (mode
< 0 || mode
> 0777 || *ptr
!= '\0') {
228 err
= -1; /* invalid mode, skip */
230 (void) snprintf(errstring
, MAX_LINELEN
,
232 ": line %d, invalid mode -- %s\n",
234 (*errmsg
)(errstring
);
239 dev_list
= strtok_r(last
, field_delims
, &last
);
240 if (dev_list
== NULL
) {
241 err
= -1; /* empty device list, skip */
243 (void) snprintf(errstring
, MAX_LINELEN
,
245 ": line %d, empty device list -- %s\n",
247 (*errmsg
)(errstring
);
252 device
= strtok_r(dev_list
, ":", &last
);
253 while (device
!= NULL
) {
254 if ((device
[0] != '/') || (strlen(device
) <= 1)) {
256 } else if (dir_dev_acc("/", &device
[1], uid
, gid
, mode
,
260 device
= strtok_r(last
, ":", &last
);
268 * returns 0 if resolved, -1 otherwise.
269 * devpath: Absolute path to /dev link
270 * devfs_path: Returns malloced string: /devices path w/out "/devices"
273 devfs_resolve_link(char *devpath
, char **devfs_path
)
275 char contents
[PATH_MAX
+ 1];
276 char stage_link
[PATH_MAX
+ 1];
279 char *slashdev
= "/dev/";
285 linksize
= readlink(devpath
, contents
, PATH_MAX
);
290 contents
[linksize
] = '\0';
294 * if the link contents is not a minor node assume
295 * that link contents is really a pointer to another
296 * link, and if so recurse and read its link contents.
298 if (is_minor_node((const char *)contents
, (const char **)&ptr
) !=
300 if (strncmp(contents
, slashdev
, strlen(slashdev
)) == 0) {
301 /* absolute path, starting with /dev */
302 (void) strcpy(stage_link
, contents
);
304 /* relative path, prefix devpath */
305 if ((ptr
= strrchr(devpath
, '/')) == NULL
) {
310 (void) strcpy(stage_link
, devpath
);
312 (void) strcat(stage_link
, "/");
313 (void) strcat(stage_link
, contents
);
316 return (devfs_resolve_link(stage_link
, devfs_path
));
320 *devfs_path
= strdup(ptr
);
321 if (*devfs_path
== NULL
) {
330 * check a logindevperm line for a driver list and match this against
331 * the driver of the minor node
332 * returns 0 if no drivers were specified or a driver match
335 check_driver_match(char *path
, char *line
)
337 char *drv
, *driver
, *lasts
;
338 char *devfs_path
= NULL
;
339 char saveline
[MAX_LINELEN
];
342 if (devfs_resolve_link(path
, &devfs_path
) == 0) {
344 char pwd_buf
[PATH_MAX
];
347 /* truncate on : so we can take a snapshot */
348 (void) strcpy(pwd_buf
, devfs_path
);
349 p
= strrchr(pwd_buf
, ':');
352 node
= di_init(pwd_buf
, DINFOMINOR
);
356 drv
= di_driver_name(node
);
365 (void) strcpy(saveline
, line
);
367 p
= strstr(saveline
, "driver");
372 driver
= strtok_r(p
, "=", &lasts
);
374 if (strcmp(driver
, "driver") == 0) {
375 driver
= strtok_r(NULL
, ", \t\n", &lasts
);
377 if (strcmp(driver
, drv
) == 0) {
380 driver
= strtok_r(NULL
, ", \t\n", &lasts
);
389 * Check whether the user has logged onto "/dev/console" or "/dev/vt/#".
392 is_login_user(uid_t uid
)
395 struct passwd pwd
, *ppwd
;
396 char pwd_buf
[NSS_BUFLEN_PASSWD
];
399 if ((getpwuid_r(uid
, &pwd
, pwd_buf
, NSS_BUFLEN_PASSWD
, &ppwd
) != 0) ||
405 while ((utx
= getutxent()) != NULL
) {
406 if (utx
->ut_type
== USER_PROCESS
&&
407 strncmp(utx
->ut_user
, ppwd
->pw_name
,
408 strlen(ppwd
->pw_name
)) == 0 && (strncmp(utx
->ut_line
,
409 "console", strlen("console")) == 0 || strncmp(utx
->ut_line
,
410 "vt", strlen("vt")) == 0)) {
422 * Apply owner/group/perms to all files (except "." and "..")
424 * This function is recursive. We start with "/" and the rest of the pathname
425 * in left_to_do argument, and we walk the entire pathname which may contain
426 * regular expressions or '*' for each directory name or basename.
429 dir_dev_acc(char *path
, char *left_to_do
, uid_t uid
, gid_t gid
, mode_t mode
,
430 char *line
, void (*errmsg
)(char *))
432 struct stat stat_buf
;
434 char errstring
[MAX_LINELEN
];
439 char *name
, *newpath
, *remainder_path
;
443 * Determine if the search needs to be performed via finddev,
444 * which returns only persisted names in the global /dev, or
445 * readdir, for paths other than /dev and non-global zones.
446 * This use of finddev avoids triggering potential implicit
447 * reconfig for names managed by logindevperm but not present
450 if (!device_exists(path
)) {
453 if (stat(path
, &stat_buf
) == -1) {
455 * ENOENT errors are expected errors when there are
456 * dangling /dev device links. Ignore them silently
458 if (errno
== ENOENT
) {
462 (void) snprintf(errstring
, MAX_LINELEN
,
463 "failed to stat %s: %s\n", path
,
465 (*errmsg
)(errstring
);
469 if (!S_ISDIR(stat_buf
.st_mode
)) {
470 if (strlen(left_to_do
) == 0) {
471 /* finally check the driver matches */
472 if (check_driver_match(path
, line
) == 0) {
474 * if the owner of device has been
475 * login, the ownership and mode
476 * should be set already. in
477 * this case, do not set the
480 if (is_login_user(stat_buf
.st_uid
)) {
484 /* we are done, set the permissions */
485 if (setdevaccess(path
,
486 uid
, gid
, mode
, errmsg
)) {
496 if (finddev_readdir(path
, &handle
) != 0)
499 p
= strchr(left_to_do
, '/');
502 newpath
= (char *)malloc(MAXPATHLEN
);
503 if (newpath
== NULL
) {
504 finddev_close(handle
);
507 match
= (char *)calloc(MAXPATHLEN
+ 2, 1);
509 finddev_close(handle
);
514 /* transform pattern into ^pattern$ for exact match */
515 if (snprintf(match
, MAXPATHLEN
+ 2, "^%.*s$",
516 p
? (p
- left_to_do
) : strlen(left_to_do
), left_to_do
) >=
518 finddev_close(handle
);
524 if (strcmp(match
, "^*$") == 0) {
527 if (regcomp(®ex
, match
, REG_EXTENDED
) != 0) {
530 finddev_close(handle
);
535 while ((name
= (char *)finddev_next(handle
)) != NULL
) {
537 regexec(®ex
, name
, 0, NULL
, 0) == 0) {
538 if (strcmp(path
, "/") == 0) {
539 (void) snprintf(newpath
,
540 MAXPATHLEN
, "%s%s", path
, name
);
542 (void) snprintf(newpath
,
543 MAXPATHLEN
, "%s/%s", path
, name
);
547 * recurse but adjust what is still left to do
549 remainder_path
= (p
?
550 left_to_do
+ (p
- left_to_do
) + 1 :
551 &left_to_do
[strlen(left_to_do
)]);
552 if (dir_dev_acc(newpath
, remainder_path
,
553 uid
, gid
, mode
, line
, errmsg
)) {
559 finddev_close(handle
);
570 * di_devperm_login - modify access of devices in /etc/logindevperm
571 * by changing owner/group/permissions to that of ttyn.
574 di_devperm_login(const char *ttyn
, uid_t uid
, gid_t gid
,
575 void (*errmsg
)(char *))
578 struct group grp
, *grpp
;
580 char grbuf
[NSS_BUFLEN_GROUP
];
586 (*errmsg
)("di_devperm_login: NULL tty device\n");
590 if (getgrnam_r("tty", &grp
, grbuf
, NSS_BUFLEN_GROUP
, &grpp
) != 0) {
591 tty_gid
= grpp
->gr_gid
;
594 * this should never happen, but if it does set
595 * group to tty's traditional value.
600 /* set the login console device permission */
601 err
= setdevaccess((char *)ttyn
, uid
, tty_gid
,
602 S_IRUSR
|S_IWUSR
|S_IWGRP
, errmsg
);
607 /* set the device permissions */
608 return (logindevperm(ttyn
, uid
, gid
, errmsg
));
612 * di_devperm_logout - clean up access of devices in /etc/logindevperm
613 * by resetting owner/group/permissions.
616 di_devperm_logout(const char *ttyn
)
625 pwd
= getpwnam("root");
627 root_uid
= pwd
->pw_uid
;
628 root_gid
= pwd
->pw_gid
;
631 * this should never happen, but if it does set user
632 * and group to root's traditional values.
638 return (logindevperm(ttyn
, root_uid
, root_gid
, NULL
));
642 logerror(char *errstring
)
644 syslog(LOG_AUTH
| LOG_CRIT
, "%s", errstring
);
649 * Tokens are separated by ' ', '\t', ':', '=', '&', '|', ';', '\n', or '\0'
652 getnexttoken(char *next
, char **nextp
, char **tokenpp
, char *tchar
)
659 while (*cp
== ' ' || *cp
== '\t') {
660 cp
++; /* skip leading spaces */
662 tokenp
= cp
; /* start of token */
663 while (*cp
!= '\0' && *cp
!= '\n' && *cp
!= ' ' && *cp
!= '\t' &&
664 *cp
!= ':' && *cp
!= '=' && *cp
!= '&' &&
665 *cp
!= '|' && *cp
!= ';') {
666 cp
++; /* point to next character */
669 * If terminating character is a space or tab, look ahead to see if
670 * there's another terminator that's not a space or a tab.
671 * (This code handles trailing spaces.)
673 if (*cp
== ' ' || *cp
== '\t') {
675 while (*++cp1
== ' ' || *cp1
== '\t')
677 if (*cp1
== '=' || *cp1
== ':' || *cp1
== '&' || *cp1
== '|' ||
678 *cp1
== ';' || *cp1
== '\n' || *cp1
== '\0') {
679 *cp
= NULL
; /* terminate token */
684 *tchar
= *cp
; /* save terminating character */
685 if (*tchar
== '\0') {
689 *cp
++ = '\0'; /* terminate token, point to next */
690 *nextp
= cp
; /* set pointer to next character */
691 if (cp
- tokenp
- 1 == 0) {
699 * get a decimal octal or hex number. Handle '~' for one's complement.
702 getvalue(char *token
, int *valuep
)
711 onescompl
++; /* perform one's complement on result */
713 } else if (*token
== '-') {
722 *valuep
= 0; /* value is 0 */
726 if (c
== 'x' || c
== 'X') {
735 while ((c
= *token
++)) {
738 if (c
>= '0' && c
<= '7') {
744 retval
= (retval
<< 3) + c
;
747 if (c
>= '0' && c
<= '9') {
753 retval
= (retval
* 10) + c
;
756 if (c
>= 'a' && c
<= 'f') {
758 } else if (c
>= 'A' && c
<= 'F') {
760 } else if (c
>= '0' && c
<= '9') {
766 retval
= (retval
<< 4) + c
;
781 * Read /etc/minor_perm, return mperm list of entries
784 i_devfs_read_minor_perm(char *drvname
, void (*errcb
)(minorperm_err_t
, int))
788 char line
[MAX_MINOR_PERM_LINE
];
790 struct mperm
*minor_perms
= NULL
;
791 struct mperm
*mptail
= NULL
;
799 * Get root/sys ids, these being the most common
801 if ((pw
= getpwnam(DEFAULT_DEV_USER
)) != NULL
) {
802 root_uid
= pw
->pw_uid
;
804 (*errcb
)(MP_CANT_FIND_USER_ERR
, 0);
805 root_uid
= (uid_t
)0; /* assume 0 is root */
807 if ((gp
= getgrnam(DEFAULT_DEV_GROUP
)) != NULL
) {
808 sys_gid
= gp
->gr_gid
;
810 (*errcb
)(MP_CANT_FIND_GROUP_ERR
, 0);
811 sys_gid
= (gid_t
)3; /* assume 3 is sys */
814 if ((pfd
= fopen(MINOR_PERM_FILE
, "r")) == NULL
) {
815 (*errcb
)(MP_FOPEN_ERR
, errno
);
818 while (fgets(line
, MAX_MINOR_PERM_LINE
, pfd
) != NULL
) {
820 /* cut off comments starting with '#' */
821 if ((cp
= strchr(line
, '#')) != NULL
)
823 /* ignore comment or blank lines */
826 mp
= (struct mperm
*)calloc(1, sizeof (struct mperm
));
828 (*errcb
)(MP_ALLOC_ERR
, sizeof (struct mperm
));
833 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
834 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
835 devfs_free_minor_perm(mp
);
838 mp
->mp_drvname
= strdup(p
);
839 if (mp
->mp_drvname
== NULL
) {
840 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
841 devfs_free_minor_perm(mp
);
843 } else if (t
== '\n' || t
== '\0') {
844 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
845 devfs_free_minor_perm(mp
);
849 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
850 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
851 devfs_free_minor_perm(mp
);
853 mp
->mp_minorname
= strdup(p
);
854 if (mp
->mp_minorname
== NULL
) {
855 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
856 devfs_free_minor_perm(mp
);
860 mp
->mp_minorname
= NULL
;
863 if (t
== '\n' || t
== '\0') {
864 devfs_free_minor_perm(mp
);
865 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
868 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
871 if (getvalue(p
, (int *)&mp
->mp_mode
) == 0) {
874 if (t
== '\n' || t
== '\0') { /* no owner or group */
877 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
880 mp
->mp_owner
= strdup(p
);
881 if (mp
->mp_owner
== NULL
) {
882 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
883 devfs_free_minor_perm(mp
);
885 } else if (t
== '\n' || t
== '\0') { /* no group */
888 if (getnexttoken(cp
, &cp
, &p
, 0) == 0) {
891 mp
->mp_group
= strdup(p
);
892 if (mp
->mp_group
== NULL
) {
893 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
894 devfs_free_minor_perm(mp
);
898 if (drvname
!= NULL
) {
900 * We only want the minor perm entry for a
901 * the named driver. The driver name is the
902 * minor in the clone case.
904 if (strcmp(mp
->mp_drvname
, "clone") == 0) {
905 if (mp
->mp_minorname
== NULL
||
906 strcmp(drvname
, mp
->mp_minorname
) != 0) {
907 devfs_free_minor_perm(mp
);
911 if (strcmp(drvname
, mp
->mp_drvname
) != 0) {
912 devfs_free_minor_perm(mp
);
917 if (minor_perms
== NULL
) {
920 mptail
->mp_next
= mp
;
925 * Compute the uid's and gid's here - there are
926 * fewer lines in the /etc/minor_perm file than there
927 * are devices to be stat(2)ed. And almost every
928 * device is 'root sys'. See 1135520.
930 if (mp
->mp_owner
== NULL
||
931 strcmp(mp
->mp_owner
, DEFAULT_DEV_USER
) == 0 ||
932 (pw
= getpwnam(mp
->mp_owner
)) == NULL
) {
933 mp
->mp_uid
= root_uid
;
935 mp
->mp_uid
= pw
->pw_uid
;
938 if (mp
->mp_group
== NULL
||
939 strcmp(mp
->mp_group
, DEFAULT_DEV_GROUP
) == 0 ||
940 (gp
= getgrnam(mp
->mp_group
)) == NULL
) {
941 mp
->mp_gid
= sys_gid
;
943 mp
->mp_gid
= gp
->gr_gid
;
947 if (fclose(pfd
) == EOF
) {
948 (*errcb
)(MP_FCLOSE_ERR
, errno
);
951 return (minor_perms
);
955 devfs_read_minor_perm(void (*errcb
)(minorperm_err_t
, int))
957 return (i_devfs_read_minor_perm(NULL
, errcb
));
960 static struct mperm
*
961 i_devfs_read_minor_perm_by_driver(char *drvname
,
962 void (*errcb
)(minorperm_err_t mp_err
, int key
))
964 return (i_devfs_read_minor_perm(drvname
, errcb
));
968 * Free mperm list of entries
971 devfs_free_minor_perm(struct mperm
*mplist
)
973 struct mperm
*mp
, *next
;
975 for (mp
= mplist
; mp
!= NULL
; mp
= next
) {
979 free(mp
->mp_drvname
);
980 if (mp
->mp_minorname
)
981 free(mp
->mp_minorname
);
991 i_devfs_add_perm_entry(nvlist_t
*nvl
, struct mperm
*mp
)
995 err
= nvlist_add_string(nvl
, mp
->mp_drvname
, mp
->mp_minorname
);
999 err
= nvlist_add_int32(nvl
, "mode", (int32_t)mp
->mp_mode
);
1003 err
= nvlist_add_uint32(nvl
, "uid", mp
->mp_uid
);
1007 err
= nvlist_add_uint32(nvl
, "gid", mp
->mp_gid
);
1012 i_devfs_minor_perm_nvlist(struct mperm
*mplist
,
1013 void (*errcb
)(minorperm_err_t
, int))
1017 nvlist_t
*nvl
= NULL
;
1019 if ((err
= nvlist_alloc(&nvl
, 0, 0)) != 0) {
1020 (*errcb
)(MP_NVLIST_ERR
, err
);
1024 for (mp
= mplist
; mp
!= NULL
; mp
= mp
->mp_next
) {
1025 if ((err
= i_devfs_add_perm_entry(nvl
, mp
)) != 0) {
1026 (*errcb
)(MP_NVLIST_ERR
, err
);
1036 * Load all minor perm entries into the kernel
1037 * Done at boot time via devfsadm
1040 devfs_load_minor_perm(struct mperm
*mplist
,
1041 void (*errcb
)(minorperm_err_t
, int))
1048 nvl
= i_devfs_minor_perm_nvlist(mplist
, errcb
);
1052 if (nvlist_pack(nvl
, &buf
, &buflen
, NV_ENCODE_NATIVE
, 0) != 0) {
1057 err
= modctl(MODLOADMINORPERM
, buf
, buflen
);
1065 * Add/remove minor perm entry for a driver
1068 i_devfs_update_minor_perm(char *drv
, int ctl
,
1069 void (*errcb
)(minorperm_err_t
, int))
1075 struct mperm
*mplist
;
1077 mplist
= i_devfs_read_minor_perm_by_driver(drv
, errcb
);
1079 nvl
= i_devfs_minor_perm_nvlist(mplist
, errcb
);
1084 if (nvlist_pack(nvl
, &buf
, &buflen
, NV_ENCODE_NATIVE
, 0) != 0) {
1089 err
= modctl(ctl
, buf
, buflen
);
1091 devfs_free_minor_perm(mplist
);
1098 devfs_add_minor_perm(char *drv
,
1099 void (*errcb
)(minorperm_err_t
, int))
1101 return (i_devfs_update_minor_perm(drv
, MODADDMINORPERM
, errcb
));
1105 devfs_rm_minor_perm(char *drv
,
1106 void (*errcb
)(minorperm_err_t
, int))
1108 return (i_devfs_update_minor_perm(drv
, MODREMMINORPERM
, errcb
));
1112 * is_blank() returns 1 (true) if a line specified is composed of
1113 * whitespace characters only. otherwise, it returns 0 (false).
1115 * Note. the argument (line) must be null-terminated.
1118 is_blank(char *line
)
1120 for (/* nothing */; *line
!= '\0'; line
++)
1121 if (!isspace(*line
))