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 */
38 #include <nss_dbdefs.h>
42 #include <sys/types.h>
45 #include <sys/sunddi.h>
46 #include <sys/devinfo_impl.h>
47 #include <sys/hwconf.h>
48 #include <sys/modctl.h>
49 #include <libnvpair.h>
50 #include <device_info.h>
53 #include <libdevinfo.h>
58 extern int is_minor_node(const char *, const char **);
60 static int is_login_user(uid_t
);
61 static int logindevperm(const char *, uid_t
, gid_t
, void (*)());
62 static int dir_dev_acc(char *, char *, uid_t
, gid_t
, mode_t
, char *line
,
64 static int setdevaccess(char *, uid_t
, gid_t
, mode_t
, void (*)());
65 static void logerror(char *);
67 static int is_blank(char *);
69 #define MAX_LINELEN 256
70 #define LOGINDEVPERM "/etc/logindevperm"
71 #define DIRWILD "/*" /* directory wildcard */
72 #define DIRWLDLEN 2 /* strlen(DIRWILD) */
75 * Revoke all access to a device node and make sure that there are
76 * no interposed streams devices attached. Must be called before a
77 * device is actually opened.
78 * When fdetach is called, the underlying device node is revealed; it
79 * will have the previous owner and that owner can re-attach; so we
81 * Ignore non-existent devices.
84 setdevaccess(char *dev
, uid_t uid
, gid_t gid
, mode_t mode
,
85 void (*errmsg
)(char *))
87 int err
= 0, local_errno
;
88 char errstring
[MAX_LINELEN
];
91 if (chown(dev
, uid
, gid
) == -1) {
92 if (errno
== ENOENT
) /* no such file */
99 * don't fdetach block devices, as it will unmount them
101 if (!((stat(dev
, &st
) == 0) && ((st
.st_mode
& S_IFMT
) == S_IFBLK
))) {
102 while (fdetach(dev
) == 0) {
103 if (chown(dev
, uid
, gid
) == -1) {
109 (void) snprintf(errstring
, MAX_LINELEN
,
110 "failed to chown device %s: %s\n",
111 dev
, strerror(local_errno
));
112 (*errmsg
)(errstring
);
117 * strip_acl sets an acl and changes the files owner/group
119 err
= acl_strip(dev
, uid
, gid
, mode
);
123 * If the file system returned ENOSYS, we know that it
124 * doesn't support ACLs, therefore, we must assume that
125 * there were no ACLs to remove in the first place.
128 if (errno
!= ENOSYS
) {
132 (void) snprintf(errstring
, MAX_LINELEN
,
133 "failed to set acl on device %s: %s\n",
134 dev
, strerror(errno
));
135 (*errmsg
)(errstring
);
138 if (chmod(dev
, mode
) == -1) {
141 (void) snprintf(errstring
, MAX_LINELEN
,
142 "failed to chmod device %s: %s\n",
143 dev
, strerror(errno
));
144 (*errmsg
)(errstring
);
153 * logindevperm - change owner/group/permissions of devices
154 * list in /etc/logindevperm.
157 logindevperm(const char *ttyn
, uid_t uid
, gid_t gid
, void (*errmsg
)(char *))
159 int err
= 0, lineno
= 0;
160 const char *field_delims
= " \t\n";
161 char line
[MAX_LINELEN
], errstring
[MAX_LINELEN
];
162 char saveline
[MAX_LINELEN
];
170 char ttyn_path
[PATH_MAX
+ 1];
173 if ((fp
= fopen(LOGINDEVPERM
, "r")) == NULL
) {
175 (void) snprintf(errstring
, MAX_LINELEN
,
176 LOGINDEVPERM
": open failed: %s\n",
178 (*errmsg
)(errstring
);
183 if ((n
= resolvepath(ttyn
, ttyn_path
, PATH_MAX
)) == -1)
187 while (fgets(line
, MAX_LINELEN
, fp
) != NULL
) {
189 char tmp
[PATH_MAX
+ 1];
193 if ((ptr
= strchr(line
, '#')) != NULL
)
194 *ptr
= '\0'; /* handle comments */
196 (void) strcpy(saveline
, line
);
198 console
= strtok_r(line
, field_delims
, &last
);
200 continue; /* ignore blank lines */
202 if ((n
= resolvepath(console
, tmp
, PATH_MAX
)) == -1)
206 if (strcmp(ttyn_path
, tmp
) != 0)
209 mode_str
= strtok_r(last
, field_delims
, &last
);
210 if (mode_str
== NULL
) {
211 err
= -1; /* invalid entry, skip */
213 (void) snprintf(errstring
, MAX_LINELEN
,
215 ": line %d, invalid entry -- %s\n",
217 (*errmsg
)(errstring
);
222 /* convert string to octal value */
223 mode
= strtol(mode_str
, &ptr
, 8);
224 if (mode
< 0 || mode
> 0777 || *ptr
!= '\0') {
225 err
= -1; /* invalid mode, skip */
227 (void) snprintf(errstring
, MAX_LINELEN
,
229 ": line %d, invalid mode -- %s\n",
231 (*errmsg
)(errstring
);
236 dev_list
= strtok_r(last
, field_delims
, &last
);
237 if (dev_list
== NULL
) {
238 err
= -1; /* empty device list, skip */
240 (void) snprintf(errstring
, MAX_LINELEN
,
242 ": line %d, empty device list -- %s\n",
244 (*errmsg
)(errstring
);
249 device
= strtok_r(dev_list
, ":", &last
);
250 while (device
!= NULL
) {
251 if ((device
[0] != '/') || (strlen(device
) <= 1)) {
253 } else if (dir_dev_acc("/", &device
[1], uid
, gid
, mode
,
257 device
= strtok_r(last
, ":", &last
);
265 * returns 0 if resolved, -1 otherwise.
266 * devpath: Absolute path to /dev link
267 * devfs_path: Returns malloced string: /devices path w/out "/devices"
270 devfs_resolve_link(char *devpath
, char **devfs_path
)
272 char contents
[PATH_MAX
+ 1];
273 char stage_link
[PATH_MAX
+ 1];
276 char *slashdev
= "/dev/";
282 linksize
= readlink(devpath
, contents
, PATH_MAX
);
287 contents
[linksize
] = '\0';
291 * if the link contents is not a minor node assume
292 * that link contents is really a pointer to another
293 * link, and if so recurse and read its link contents.
295 if (is_minor_node((const char *)contents
, (const char **)&ptr
) !=
297 if (strncmp(contents
, slashdev
, strlen(slashdev
)) == 0) {
298 /* absolute path, starting with /dev */
299 (void) strcpy(stage_link
, contents
);
301 /* relative path, prefix devpath */
302 if ((ptr
= strrchr(devpath
, '/')) == NULL
) {
307 (void) strcpy(stage_link
, devpath
);
309 (void) strcat(stage_link
, "/");
310 (void) strcat(stage_link
, contents
);
313 return (devfs_resolve_link(stage_link
, devfs_path
));
317 *devfs_path
= strdup(ptr
);
318 if (*devfs_path
== NULL
) {
327 * check a logindevperm line for a driver list and match this against
328 * the driver of the minor node
329 * returns 0 if no drivers were specified or a driver match
332 check_driver_match(char *path
, char *line
)
334 char *drv
, *driver
, *lasts
;
335 char *devfs_path
= NULL
;
336 char saveline
[MAX_LINELEN
];
339 if (devfs_resolve_link(path
, &devfs_path
) == 0) {
341 char pwd_buf
[PATH_MAX
];
344 /* truncate on : so we can take a snapshot */
345 (void) strcpy(pwd_buf
, devfs_path
);
346 p
= strrchr(pwd_buf
, ':');
349 node
= di_init(pwd_buf
, DINFOMINOR
);
353 drv
= di_driver_name(node
);
362 (void) strcpy(saveline
, line
);
364 p
= strstr(saveline
, "driver");
369 driver
= strtok_r(p
, "=", &lasts
);
371 if (strcmp(driver
, "driver") == 0) {
372 driver
= strtok_r(NULL
, ", \t\n", &lasts
);
374 if (strcmp(driver
, drv
) == 0) {
377 driver
= strtok_r(NULL
, ", \t\n", &lasts
);
386 * Check whether the user has logged onto "/dev/console" or "/dev/vt/#".
389 is_login_user(uid_t uid
)
392 struct passwd pwd
, *ppwd
;
393 char pwd_buf
[NSS_BUFLEN_PASSWD
];
396 if ((getpwuid_r(uid
, &pwd
, pwd_buf
, NSS_BUFLEN_PASSWD
, &ppwd
) != 0) ||
402 while ((utx
= getutxent()) != NULL
) {
403 if (utx
->ut_type
== USER_PROCESS
&&
404 strncmp(utx
->ut_user
, ppwd
->pw_name
,
405 strlen(ppwd
->pw_name
)) == 0 && (strncmp(utx
->ut_line
,
406 "console", strlen("console")) == 0 || strncmp(utx
->ut_line
,
407 "vt", strlen("vt")) == 0)) {
419 * Apply owner/group/perms to all files (except "." and "..")
421 * This function is recursive. We start with "/" and the rest of the pathname
422 * in left_to_do argument, and we walk the entire pathname which may contain
423 * regular expressions or '*' for each directory name or basename.
426 dir_dev_acc(char *path
, char *left_to_do
, uid_t uid
, gid_t gid
, mode_t mode
,
427 char *line
, void (*errmsg
)(char *))
429 struct stat stat_buf
;
431 char errstring
[MAX_LINELEN
];
436 char *name
, *newpath
, *remainder_path
;
440 * Determine if the search needs to be performed via finddev,
441 * which returns only persisted names in the global /dev, or
442 * readdir, for paths other than /dev and non-global zones.
443 * This use of finddev avoids triggering potential implicit
444 * reconfig for names managed by logindevperm but not present
447 if (!device_exists(path
)) {
450 if (stat(path
, &stat_buf
) == -1) {
452 * ENOENT errors are expected errors when there are
453 * dangling /dev device links. Ignore them silently
455 if (errno
== ENOENT
) {
459 (void) snprintf(errstring
, MAX_LINELEN
,
460 "failed to stat %s: %s\n", path
,
462 (*errmsg
)(errstring
);
466 if (!S_ISDIR(stat_buf
.st_mode
)) {
467 if (strlen(left_to_do
) == 0) {
468 /* finally check the driver matches */
469 if (check_driver_match(path
, line
) == 0) {
471 * if the owner of device has been
472 * login, the ownership and mode
473 * should be set already. in
474 * this case, do not set the
477 if (is_login_user(stat_buf
.st_uid
)) {
481 /* we are done, set the permissions */
482 if (setdevaccess(path
,
483 uid
, gid
, mode
, errmsg
)) {
493 if (finddev_readdir(path
, &handle
) != 0)
496 p
= strchr(left_to_do
, '/');
499 newpath
= (char *)malloc(MAXPATHLEN
);
500 if (newpath
== NULL
) {
501 finddev_close(handle
);
504 match
= (char *)calloc(MAXPATHLEN
+ 2, 1);
506 finddev_close(handle
);
511 /* transform pattern into ^pattern$ for exact match */
512 if (snprintf(match
, MAXPATHLEN
+ 2, "^%.*s$",
513 p
? (p
- left_to_do
) : strlen(left_to_do
), left_to_do
) >=
515 finddev_close(handle
);
521 if (strcmp(match
, "^*$") == 0) {
524 if (regcomp(®ex
, match
, REG_EXTENDED
) != 0) {
527 finddev_close(handle
);
532 while ((name
= (char *)finddev_next(handle
)) != NULL
) {
534 regexec(®ex
, name
, 0, NULL
, 0) == 0) {
535 if (strcmp(path
, "/") == 0) {
536 (void) snprintf(newpath
,
537 MAXPATHLEN
, "%s%s", path
, name
);
539 (void) snprintf(newpath
,
540 MAXPATHLEN
, "%s/%s", path
, name
);
544 * recurse but adjust what is still left to do
546 remainder_path
= (p
?
547 left_to_do
+ (p
- left_to_do
) + 1 :
548 &left_to_do
[strlen(left_to_do
)]);
549 if (dir_dev_acc(newpath
, remainder_path
,
550 uid
, gid
, mode
, line
, errmsg
)) {
556 finddev_close(handle
);
567 * di_devperm_login - modify access of devices in /etc/logindevperm
568 * by changing owner/group/permissions to that of ttyn.
571 di_devperm_login(const char *ttyn
, uid_t uid
, gid_t gid
,
572 void (*errmsg
)(char *))
575 struct group grp
, *grpp
;
577 char grbuf
[NSS_BUFLEN_GROUP
];
583 (*errmsg
)("di_devperm_login: NULL tty device\n");
587 if (getgrnam_r("tty", &grp
, grbuf
, NSS_BUFLEN_GROUP
, &grpp
) != 0) {
588 tty_gid
= grpp
->gr_gid
;
591 * this should never happen, but if it does set
592 * group to tty's traditional value.
597 /* set the login console device permission */
598 err
= setdevaccess((char *)ttyn
, uid
, tty_gid
,
599 S_IRUSR
|S_IWUSR
|S_IWGRP
, errmsg
);
604 /* set the device permissions */
605 return (logindevperm(ttyn
, uid
, gid
, errmsg
));
609 * di_devperm_logout - clean up access of devices in /etc/logindevperm
610 * by resetting owner/group/permissions.
613 di_devperm_logout(const char *ttyn
)
622 pwd
= getpwnam("root");
624 root_uid
= pwd
->pw_uid
;
625 root_gid
= pwd
->pw_gid
;
628 * this should never happen, but if it does set user
629 * and group to root's traditional values.
635 return (logindevperm(ttyn
, root_uid
, root_gid
, NULL
));
639 logerror(char *errstring
)
641 syslog(LOG_AUTH
| LOG_CRIT
, "%s", errstring
);
646 * Tokens are separated by ' ', '\t', ':', '=', '&', '|', ';', '\n', or '\0'
649 getnexttoken(char *next
, char **nextp
, char **tokenpp
, char *tchar
)
656 while (*cp
== ' ' || *cp
== '\t') {
657 cp
++; /* skip leading spaces */
659 tokenp
= cp
; /* start of token */
660 while (*cp
!= '\0' && *cp
!= '\n' && *cp
!= ' ' && *cp
!= '\t' &&
661 *cp
!= ':' && *cp
!= '=' && *cp
!= '&' &&
662 *cp
!= '|' && *cp
!= ';') {
663 cp
++; /* point to next character */
666 * If terminating character is a space or tab, look ahead to see if
667 * there's another terminator that's not a space or a tab.
668 * (This code handles trailing spaces.)
670 if (*cp
== ' ' || *cp
== '\t') {
672 while (*++cp1
== ' ' || *cp1
== '\t')
674 if (*cp1
== '=' || *cp1
== ':' || *cp1
== '&' || *cp1
== '|' ||
675 *cp1
== ';' || *cp1
== '\n' || *cp1
== '\0') {
676 *cp
= '\0'; /* terminate token */
681 *tchar
= *cp
; /* save terminating character */
682 if (*tchar
== '\0') {
686 *cp
++ = '\0'; /* terminate token, point to next */
687 *nextp
= cp
; /* set pointer to next character */
688 if (cp
- tokenp
- 1 == 0) {
696 * get a decimal octal or hex number. Handle '~' for one's complement.
699 getvalue(char *token
, int *valuep
)
708 onescompl
++; /* perform one's complement on result */
710 } else if (*token
== '-') {
719 *valuep
= 0; /* value is 0 */
723 if (c
== 'x' || c
== 'X') {
732 while ((c
= *token
++)) {
735 if (c
>= '0' && c
<= '7') {
741 retval
= (retval
<< 3) + c
;
744 if (c
>= '0' && c
<= '9') {
750 retval
= (retval
* 10) + c
;
753 if (c
>= 'a' && c
<= 'f') {
755 } else if (c
>= 'A' && c
<= 'F') {
757 } else if (c
>= '0' && c
<= '9') {
763 retval
= (retval
<< 4) + c
;
778 * Read /etc/minor_perm, return mperm list of entries
781 i_devfs_read_minor_perm(char *drvname
, void (*errcb
)(minorperm_err_t
, int))
785 char line
[MAX_MINOR_PERM_LINE
];
787 struct mperm
*minor_perms
= NULL
;
788 struct mperm
*mptail
= NULL
;
796 * Get root/sys ids, these being the most common
798 if ((pw
= getpwnam(DEFAULT_DEV_USER
)) != NULL
) {
799 root_uid
= pw
->pw_uid
;
801 (*errcb
)(MP_CANT_FIND_USER_ERR
, 0);
802 root_uid
= (uid_t
)0; /* assume 0 is root */
804 if ((gp
= getgrnam(DEFAULT_DEV_GROUP
)) != NULL
) {
805 sys_gid
= gp
->gr_gid
;
807 (*errcb
)(MP_CANT_FIND_GROUP_ERR
, 0);
808 sys_gid
= (gid_t
)3; /* assume 3 is sys */
811 if ((pfd
= fopen(MINOR_PERM_FILE
, "r")) == NULL
) {
812 (*errcb
)(MP_FOPEN_ERR
, errno
);
815 while (fgets(line
, MAX_MINOR_PERM_LINE
, pfd
) != NULL
) {
817 /* cut off comments starting with '#' */
818 if ((cp
= strchr(line
, '#')) != NULL
)
820 /* ignore comment or blank lines */
823 mp
= (struct mperm
*)calloc(1, sizeof (struct mperm
));
825 (*errcb
)(MP_ALLOC_ERR
, sizeof (struct mperm
));
830 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
831 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
832 devfs_free_minor_perm(mp
);
835 mp
->mp_drvname
= strdup(p
);
836 if (mp
->mp_drvname
== NULL
) {
837 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
838 devfs_free_minor_perm(mp
);
840 } else if (t
== '\n' || t
== '\0') {
841 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
842 devfs_free_minor_perm(mp
);
846 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
847 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
848 devfs_free_minor_perm(mp
);
850 mp
->mp_minorname
= strdup(p
);
851 if (mp
->mp_minorname
== NULL
) {
852 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
853 devfs_free_minor_perm(mp
);
857 mp
->mp_minorname
= NULL
;
860 if (t
== '\n' || t
== '\0') {
861 devfs_free_minor_perm(mp
);
862 (*errcb
)(MP_IGNORING_LINE_ERR
, ln
);
865 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
868 if (getvalue(p
, (int *)&mp
->mp_mode
) == 0) {
871 if (t
== '\n' || t
== '\0') { /* no owner or group */
874 if (getnexttoken(cp
, &cp
, &p
, &t
) == 0) {
877 mp
->mp_owner
= strdup(p
);
878 if (mp
->mp_owner
== NULL
) {
879 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
880 devfs_free_minor_perm(mp
);
882 } else if (t
== '\n' || t
== '\0') { /* no group */
885 if (getnexttoken(cp
, &cp
, &p
, 0) == 0) {
888 mp
->mp_group
= strdup(p
);
889 if (mp
->mp_group
== NULL
) {
890 (*errcb
)(MP_ALLOC_ERR
, strlen(p
)+1);
891 devfs_free_minor_perm(mp
);
895 if (drvname
!= NULL
) {
897 * We only want the minor perm entry for a
898 * the named driver. The driver name is the
899 * minor in the clone case.
901 if (strcmp(mp
->mp_drvname
, "clone") == 0) {
902 if (mp
->mp_minorname
== NULL
||
903 strcmp(drvname
, mp
->mp_minorname
) != 0) {
904 devfs_free_minor_perm(mp
);
908 if (strcmp(drvname
, mp
->mp_drvname
) != 0) {
909 devfs_free_minor_perm(mp
);
914 if (minor_perms
== NULL
) {
917 mptail
->mp_next
= mp
;
922 * Compute the uid's and gid's here - there are
923 * fewer lines in the /etc/minor_perm file than there
924 * are devices to be stat(2)ed. And almost every
925 * device is 'root sys'. See 1135520.
927 if (mp
->mp_owner
== NULL
||
928 strcmp(mp
->mp_owner
, DEFAULT_DEV_USER
) == 0 ||
929 (pw
= getpwnam(mp
->mp_owner
)) == NULL
) {
930 mp
->mp_uid
= root_uid
;
932 mp
->mp_uid
= pw
->pw_uid
;
935 if (mp
->mp_group
== NULL
||
936 strcmp(mp
->mp_group
, DEFAULT_DEV_GROUP
) == 0 ||
937 (gp
= getgrnam(mp
->mp_group
)) == NULL
) {
938 mp
->mp_gid
= sys_gid
;
940 mp
->mp_gid
= gp
->gr_gid
;
944 if (fclose(pfd
) == EOF
) {
945 (*errcb
)(MP_FCLOSE_ERR
, errno
);
948 return (minor_perms
);
952 devfs_read_minor_perm(void (*errcb
)(minorperm_err_t
, int))
954 return (i_devfs_read_minor_perm(NULL
, errcb
));
957 static struct mperm
*
958 i_devfs_read_minor_perm_by_driver(char *drvname
,
959 void (*errcb
)(minorperm_err_t mp_err
, int key
))
961 return (i_devfs_read_minor_perm(drvname
, errcb
));
965 * Free mperm list of entries
968 devfs_free_minor_perm(struct mperm
*mplist
)
970 struct mperm
*mp
, *next
;
972 for (mp
= mplist
; mp
!= NULL
; mp
= next
) {
975 free(mp
->mp_drvname
);
976 free(mp
->mp_minorname
);
984 i_devfs_add_perm_entry(nvlist_t
*nvl
, struct mperm
*mp
)
988 err
= nvlist_add_string(nvl
, mp
->mp_drvname
, mp
->mp_minorname
);
992 err
= nvlist_add_int32(nvl
, "mode", (int32_t)mp
->mp_mode
);
996 err
= nvlist_add_uint32(nvl
, "uid", mp
->mp_uid
);
1000 err
= nvlist_add_uint32(nvl
, "gid", mp
->mp_gid
);
1005 i_devfs_minor_perm_nvlist(struct mperm
*mplist
,
1006 void (*errcb
)(minorperm_err_t
, int))
1010 nvlist_t
*nvl
= NULL
;
1012 if ((err
= nvlist_alloc(&nvl
, 0, 0)) != 0) {
1013 (*errcb
)(MP_NVLIST_ERR
, err
);
1017 for (mp
= mplist
; mp
!= NULL
; mp
= mp
->mp_next
) {
1018 if ((err
= i_devfs_add_perm_entry(nvl
, mp
)) != 0) {
1019 (*errcb
)(MP_NVLIST_ERR
, err
);
1029 * Load all minor perm entries into the kernel
1030 * Done at boot time via devfsadm
1033 devfs_load_minor_perm(struct mperm
*mplist
,
1034 void (*errcb
)(minorperm_err_t
, int))
1041 nvl
= i_devfs_minor_perm_nvlist(mplist
, errcb
);
1045 if (nvlist_pack(nvl
, &buf
, &buflen
, NV_ENCODE_NATIVE
, 0) != 0) {
1050 err
= modctl(MODLOADMINORPERM
, buf
, buflen
);
1058 * Add/remove minor perm entry for a driver
1061 i_devfs_update_minor_perm(char *drv
, int ctl
,
1062 void (*errcb
)(minorperm_err_t
, int))
1068 struct mperm
*mplist
;
1070 mplist
= i_devfs_read_minor_perm_by_driver(drv
, errcb
);
1072 nvl
= i_devfs_minor_perm_nvlist(mplist
, errcb
);
1077 if (nvlist_pack(nvl
, &buf
, &buflen
, NV_ENCODE_NATIVE
, 0) != 0) {
1082 err
= modctl(ctl
, buf
, buflen
);
1084 devfs_free_minor_perm(mplist
);
1091 devfs_add_minor_perm(char *drv
,
1092 void (*errcb
)(minorperm_err_t
, int))
1094 return (i_devfs_update_minor_perm(drv
, MODADDMINORPERM
, errcb
));
1098 devfs_rm_minor_perm(char *drv
,
1099 void (*errcb
)(minorperm_err_t
, int))
1101 return (i_devfs_update_minor_perm(drv
, MODREMMINORPERM
, errcb
));
1105 * is_blank() returns 1 (true) if a line specified is composed of
1106 * whitespace characters only. otherwise, it returns 0 (false).
1108 * Note. the argument (line) must be null-terminated.
1111 is_blank(char *line
)
1113 for (/* nothing */; *line
!= '\0'; line
++)
1114 if (!isspace(*line
))