annotate usr/src/cmd/smbsrv/smbadm/smbadm.c @ 10717:fe0545fc3cdd

6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API 6877755 smbd should not route stderr, stdout to /dev/null 6882701 Wrong error message for attempt to map local user to Windows group, or vice versa 6885105 Potential for deadlock in smb_node_set_delete_on_close() 6881928 smbd core generated when running a script to join domain, set abe properties 6885538 Reduce dependencies on libsmbrdr 6820325 cifs service can't start on multi vlan+ipmp configuration
author Alan Wright <amw@Sun.COM>
date Mon, 05 Oct 2009 11:03:34 -0700
parents 3b15214a2c50
children 37e5dcdf36d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
2 * CDDL HEADER START
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
3 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
5 * Common Development and Distribution License (the "License").
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
6 * You may not use this file except in compliance with the License.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
7 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
10 * See the License for the specific language governing permissions
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
11 * and limitations under the License.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
12 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
18 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
19 * CDDL HEADER END
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
20 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
21 /*
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
23 * Use is subject to license terms.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
24 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
25
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
26 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
27 * This module contains smbadm CLI which offers smb configuration
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
28 * functionalities.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
29 */
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
30 #include <errno.h>
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
31 #include <err.h>
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
32 #include <ctype.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
33 #include <stdlib.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
34 #include <stdio.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
35 #include <syslog.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
36 #include <strings.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
37 #include <limits.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
38 #include <getopt.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
39 #include <libintl.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
40 #include <zone.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
41 #include <grp.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
42 #include <libgen.h>
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
43 #include <netinet/in.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
44 #include <smbsrv/libsmb.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
45
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
46 typedef enum {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
47 HELP_ADD_MEMBER,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
48 HELP_CREATE,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
49 HELP_DELETE,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
50 HELP_DEL_MEMBER,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
51 HELP_GET,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
52 HELP_JOIN,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
53 HELP_LIST,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
54 HELP_RENAME,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
55 HELP_SET,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
56 HELP_SHOW,
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
57 HELP_USER_DISABLE,
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
58 HELP_USER_ENABLE
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
59 } smbadm_help_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
60
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
61 #define SMBADM_CMDF_USER 0x01
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
62 #define SMBADM_CMDF_GROUP 0x02
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
63 #define SMBADM_CMDF_TYPEMASK 0x0F
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
64
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
65 #define SMBADM_ANSBUFSIZ 64
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
66
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
67 typedef struct smbadm_cmdinfo {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
68 char *name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
69 int (*func)(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
70 smbadm_help_t usage;
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
71 uint32_t flags;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
72 } smbadm_cmdinfo_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
73
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
74 smbadm_cmdinfo_t *curcmd;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
75 static char *progname;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
76
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
77 static void smbadm_usage(boolean_t);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
78 static int smbadm_join_workgroup(const char *);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
79 static int smbadm_join_domain(const char *, const char *);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
80 static boolean_t smbadm_valid_domainname(const char *);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
81 static boolean_t smbadm_valid_username(const char *);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
82 static boolean_t smbadm_valid_workgroup(const char *);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
83 static void smbadm_extract_domain(char *, char **, char **);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
84
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
85 static int smbadm_join(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
86 static int smbadm_list(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
87 static int smbadm_group_create(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
88 static int smbadm_group_delete(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
89 static int smbadm_group_rename(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
90 static int smbadm_group_show(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
91 static int smbadm_group_getprop(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
92 static int smbadm_group_setprop(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
93 static int smbadm_group_addmember(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
94 static int smbadm_group_delmember(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
95 static int smbadm_user_disable(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
96 static int smbadm_user_enable(int, char **);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
97
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
98 static smbadm_cmdinfo_t smbadm_cmdtable[] =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
99 {
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
100 { "add-member", smbadm_group_addmember, HELP_ADD_MEMBER,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
101 SMBADM_CMDF_GROUP },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
102 { "create", smbadm_group_create, HELP_CREATE,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
103 SMBADM_CMDF_GROUP },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
104 { "delete", smbadm_group_delete, HELP_DELETE,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
105 SMBADM_CMDF_GROUP },
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
106 { "disable-user", smbadm_user_disable, HELP_USER_DISABLE,
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
107 SMBADM_CMDF_USER },
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
108 { "enable-user", smbadm_user_enable, HELP_USER_ENABLE,
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
109 SMBADM_CMDF_USER },
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
110 { "get", smbadm_group_getprop, HELP_GET,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
111 SMBADM_CMDF_GROUP },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
112 { "join", smbadm_join, HELP_JOIN, 0 },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
113 { "list", smbadm_list, HELP_LIST, 0 },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
114 { "remove-member", smbadm_group_delmember, HELP_DEL_MEMBER,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
115 SMBADM_CMDF_GROUP },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
116 { "rename", smbadm_group_rename, HELP_RENAME,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
117 SMBADM_CMDF_GROUP },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
118 { "set", smbadm_group_setprop, HELP_SET,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
119 SMBADM_CMDF_GROUP },
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
120 { "show", smbadm_group_show, HELP_SHOW,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
121 SMBADM_CMDF_GROUP },
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
122 };
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
123
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
124 #define SMBADM_NCMD (sizeof (smbadm_cmdtable) / sizeof (smbadm_cmdtable[0]))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
125
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
126 typedef struct smbadm_prop {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
127 char *p_name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
128 char *p_value;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
129 } smbadm_prop_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
130
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
131 typedef struct smbadm_prop_handle {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
132 char *p_name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
133 char *p_dispvalue;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
134 int (*p_setfn)(char *, smbadm_prop_t *);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
135 int (*p_getfn)(char *, smbadm_prop_t *);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
136 boolean_t (*p_chkfn)(smbadm_prop_t *);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
137 } smbadm_prop_handle_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
138
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
139 static boolean_t smbadm_prop_validate(smbadm_prop_t *prop, boolean_t chkval);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
140 static int smbadm_prop_parse(char *arg, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
141 static smbadm_prop_handle_t *smbadm_prop_gethandle(char *pname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
142
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
143 static boolean_t smbadm_chkprop_priv(smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
144 static int smbadm_setprop_tkowner(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
145 static int smbadm_getprop_tkowner(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
146 static int smbadm_setprop_backup(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
147 static int smbadm_getprop_backup(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
148 static int smbadm_setprop_restore(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
149 static int smbadm_getprop_restore(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
150 static int smbadm_setprop_desc(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
151 static int smbadm_getprop_desc(char *gname, smbadm_prop_t *prop);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
152
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
153 static smbadm_prop_handle_t smbadm_ptable[] = {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
154 {"backup", "on | off", smbadm_setprop_backup,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
155 smbadm_getprop_backup, smbadm_chkprop_priv },
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
156 {"restore", "on | off", smbadm_setprop_restore,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
157 smbadm_getprop_restore, smbadm_chkprop_priv },
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
158 {"take-ownership", "on | off", smbadm_setprop_tkowner,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
159 smbadm_getprop_tkowner, smbadm_chkprop_priv },
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
160 {"description", "<string>", smbadm_setprop_desc,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
161 smbadm_getprop_desc, NULL },
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
162 };
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
163
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
164 static int smbadm_init(void);
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
165 static void smbadm_fini(void);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
166 static const char *smbadm_pwd_strerror(int error);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
167
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
168 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
169 * Number of supported properties
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
170 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
171 #define SMBADM_NPROP (sizeof (smbadm_ptable) / sizeof (smbadm_ptable[0]))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
172
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
173 static void
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
174 smbadm_cmdusage(FILE *fp, smbadm_cmdinfo_t *cmd)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
175 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
176 switch (cmd->usage) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
177 case HELP_ADD_MEMBER:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
178 (void) fprintf(fp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
179 gettext("\t%s -m member [[-m member] ...] group\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
180 cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
181 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
182
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
183 case HELP_CREATE:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
184 (void) fprintf(fp, gettext("\t%s [-d description] group\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
185 cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
186 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
187
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
188 case HELP_DELETE:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
189 (void) fprintf(fp, gettext("\t%s group\n"), cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
190 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
191
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
192 case HELP_USER_DISABLE:
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
193 case HELP_USER_ENABLE:
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
194 (void) fprintf(fp, gettext("\t%s user\n"), cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
195 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
196
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
197 case HELP_GET:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
198 (void) fprintf(fp, gettext("\t%s [[-p property] ...] group\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
199 cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
200 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
201
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
202 case HELP_JOIN:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
203 (void) fprintf(fp, gettext("\t%s -u username domain\n"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
204 "\t%s -w workgroup\n"), cmd->name, cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
205 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
206
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
207 case HELP_LIST:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
208 (void) fprintf(fp, gettext("\t%s\n"), cmd->name);
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
209 (void) fprintf(fp,
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
210 gettext("\t\t[*] primary domain\n"));
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
211 (void) fprintf(fp, gettext("\t\t[.] local domain\n"));
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
212 (void) fprintf(fp, gettext("\t\t[-] other domains\n"));
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
213 (void) fprintf(fp,
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
214 gettext("\t\t[+] selected domain controller\n"));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
215 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
216
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
217 case HELP_DEL_MEMBER:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
218 (void) fprintf(fp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
219 gettext("\t%s -m member [[-m member] ...] group\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
220 cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
221 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
222
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
223 case HELP_RENAME:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
224 (void) fprintf(fp, gettext("\t%s group new-group\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
225 cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
226 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
227
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
228 case HELP_SET:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
229 (void) fprintf(fp, gettext("\t%s -p property=value "
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
230 "[[-p property=value] ...] group\n"), cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
231 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
232
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
233 case HELP_SHOW:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
234 (void) fprintf(fp, gettext("\t%s [-m] [-p] [group]\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
235 cmd->name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
236 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
237
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
238 default:
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
239 break;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
240 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
241
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
242 abort();
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
243 /* NOTREACHED */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
244 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
245
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
246 static void
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
247 smbadm_usage(boolean_t requested)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
248 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
249 FILE *fp = requested ? stdout : stderr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
250 boolean_t show_props = B_FALSE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
251 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
252
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
253 if (curcmd == NULL) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
254 (void) fprintf(fp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
255 gettext("usage: %s [-h | <command> [options]]\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
256 progname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
257 (void) fprintf(fp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
258 gettext("where 'command' is one of the following:\n\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
259
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
260 for (i = 0; i < SMBADM_NCMD; i++)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
261 smbadm_cmdusage(fp, &smbadm_cmdtable[i]);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
262
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
263 (void) fprintf(fp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
264 gettext("\nFor property list, run %s %s|%s\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
265 progname, "get", "set");
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
266
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
267 exit(requested ? 0 : 2);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
268 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
269
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
270 (void) fprintf(fp, gettext("usage:\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
271 smbadm_cmdusage(fp, curcmd);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
272
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
273 if (strcmp(curcmd->name, "get") == 0 ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
274 strcmp(curcmd->name, "set") == 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
275 show_props = B_TRUE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
276
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
277 if (show_props) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
278 (void) fprintf(fp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
279 gettext("\nThe following properties are supported:\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
280
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
281 (void) fprintf(fp, "\n\t%-16s %s\n\n",
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
282 "PROPERTY", "VALUES");
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
283
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
284 for (i = 0; i < SMBADM_NPROP; i++) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
285 (void) fprintf(fp, "\t%-16s %s\n",
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
286 smbadm_ptable[i].p_name,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
287 smbadm_ptable[i].p_dispvalue);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
288 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
289 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
290
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
291 exit(requested ? 0 : 2);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
292 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
293
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
294 /*
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
295 * smbadm_strcasecmplist
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
296 *
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
297 * Find a string 's' within a list of strings.
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
298 *
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
299 * Returns the index of the matching string or -1 if there is no match.
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
300 */
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
301 static int
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
302 smbadm_strcasecmplist(const char *s, ...)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
303 {
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
304 va_list ap;
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
305 char *p;
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
306 int ndx;
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
307
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
308 va_start(ap, s);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
309
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
310 for (ndx = 0; ((p = va_arg(ap, char *)) != NULL); ++ndx) {
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
311 if (strcasecmp(s, p) == 0) {
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
312 va_end(ap);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
313 return (ndx);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
314 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
315 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
316
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
317 va_end(ap);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
318 return (-1);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
319 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
320
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
321 /*
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
322 * smbadm_answer_prompt
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
323 *
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
324 * Prompt for the answer to a question. A default response must be
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
325 * specified, which will be used if the user presses <enter> without
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
326 * answering the question.
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
327 */
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
328 static int
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
329 smbadm_answer_prompt(const char *prompt, char *answer, const char *dflt)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
330 {
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
331 char buf[SMBADM_ANSBUFSIZ];
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
332 char *p;
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
333
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
334 (void) printf(gettext("%s [%s]: "), prompt, dflt);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
335
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
336 if (fgets(buf, SMBADM_ANSBUFSIZ, stdin) == NULL)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
337 return (-1);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
338
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
339 if ((p = strchr(buf, '\n')) != NULL)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
340 *p = '\0';
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
341
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
342 if (*buf == '\0')
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
343 (void) strlcpy(answer, dflt, SMBADM_ANSBUFSIZ);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
344 else
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
345 (void) strlcpy(answer, buf, SMBADM_ANSBUFSIZ);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
346
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
347 return (0);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
348 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
349
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
350 /*
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
351 * smbadm_confirm
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
352 *
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
353 * Ask a question that requires a yes/no answer.
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
354 * A default response must be specified.
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
355 */
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
356 static boolean_t
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
357 smbadm_confirm(const char *prompt, const char *dflt)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
358 {
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
359 char buf[SMBADM_ANSBUFSIZ];
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
360
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
361 for (;;) {
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
362 if (smbadm_answer_prompt(prompt, buf, dflt) < 0)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
363 return (B_FALSE);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
364
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
365 if (smbadm_strcasecmplist(buf, "n", "no", 0) >= 0)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
366 return (B_FALSE);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
367
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
368 if (smbadm_strcasecmplist(buf, "y", "yes", 0) >= 0)
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
369 return (B_TRUE);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
370
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
371 (void) printf(gettext("Please answer yes or no.\n"));
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
372 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
373 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
374
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
375 static boolean_t
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
376 smbadm_join_prompt(const char *domain)
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
377 {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
378 (void) printf(gettext("After joining %s the smb service will be "
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
379 "restarted automatically.\n"), domain);
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
380
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
381 return (smbadm_confirm("Would you like to continue?", "no"));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
382 }
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
383
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
384 static void
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
385 smbadm_restart_service(void)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
386 {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
387 if (smb_smf_restart_service() != 0) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
388 (void) fprintf(stderr,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
389 gettext("Unable to restart smb service. "
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
390 "Run 'svcs -xv smb/server' for more information."));
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
391 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
392 }
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
393
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
394 /*
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
395 * smbadm_join
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
396 *
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
397 * Join a domain or workgroup.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
398 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
399 * When joining a domain, we may receive the username, password and
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
400 * domain name in any of the following combinations. Note that the
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
401 * password is optional on the command line: if it is not provided,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
402 * we will prompt for it later.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
403 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
404 * username+password domain
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
405 * domain\username+password
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
406 * domain/username+password
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
407 * username@domain
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
408 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
409 * We allow domain\name+password or domain/name+password but not
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
410 * name+password@domain because @ is a valid password character.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
411 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
412 * If the username and domain name are passed as separate command
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
413 * line arguments, we process them directly. Otherwise we separate
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
414 * them and continue as if they were separate command line arguments.
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
415 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
416 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
417 smbadm_join(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
418 {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
419 char buf[MAXHOSTNAMELEN * 2];
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
420 char *domain = NULL;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
421 char *username = NULL;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
422 uint32_t mode = 0;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
423 char option;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
424
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
425 while ((option = getopt(argc, argv, "u:w:")) != -1) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
426 switch (option) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
427 case 'w':
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
428 if (mode != 0) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
429 (void) fprintf(stderr,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
430 gettext("-u and -w must only appear "
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
431 "once and are mutually exclusive\n"));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
432 smbadm_usage(B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
433 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
434
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
435 mode = SMB_SECMODE_WORKGRP;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
436 domain = optarg;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
437 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
438
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
439 case 'u':
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
440 if (mode != 0) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
441 (void) fprintf(stderr,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
442 gettext("-u and -w must only appear "
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
443 "once and are mutually exclusive\n"));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
444 smbadm_usage(B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
445 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
446
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
447 mode = SMB_SECMODE_DOMAIN;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
448 username = optarg;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
449
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
450 if ((domain = argv[optind]) == NULL) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
451 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
452 * The domain was not specified as a separate
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
453 * argument, check for the combination forms.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
454 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
455 (void) strlcpy(buf, username, sizeof (buf));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
456 smbadm_extract_domain(buf, &username, &domain);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
457 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
458
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
459 if ((username == NULL) || (*username == '\0')) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
460 (void) fprintf(stderr,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
461 gettext("missing username\n"));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
462 smbadm_usage(B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
463 }
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
464 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
465
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
466 default:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
467 smbadm_usage(B_FALSE);
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
468 break;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
469 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
470 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
471
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
472 if ((domain == NULL) || (*domain == '\0')) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
473 (void) fprintf(stderr, gettext("missing %s name\n"),
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
474 (mode == SMB_SECMODE_WORKGRP) ? "workgroup" : "domain");
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
475 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
476 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
477
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
478 if (mode == SMB_SECMODE_WORKGRP)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
479 return (smbadm_join_workgroup(domain));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
480 else
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
481 return (smbadm_join_domain(domain, username));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
482 }
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
483
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
484 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
485 * Workgroups comprise a collection of standalone, independently administered
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
486 * computers that use a common workgroup name. This is a peer-to-peer model
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
487 * with no formal membership mechanism.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
488 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
489 static int
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
490 smbadm_join_workgroup(const char *workgroup)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
491 {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
492 smb_joininfo_t jdi;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
493 uint32_t status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
494
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
495 bzero(&jdi, sizeof (jdi));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
496 jdi.mode = SMB_SECMODE_WORKGRP;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
497 (void) strlcpy(jdi.domain_name, workgroup, sizeof (jdi.domain_name));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
498 (void) strtrim(jdi.domain_name, " \t\n");
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
499
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
500 if (!smbadm_valid_workgroup(jdi.domain_name)) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
501 (void) fprintf(stderr, gettext("workgroup name is invalid\n"));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
502 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
503 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
504
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
505 if (!smbadm_join_prompt(jdi.domain_name))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
506 return (0);
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
507
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
508 if ((status = smb_join(&jdi)) != NT_STATUS_SUCCESS) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
509 (void) fprintf(stderr, gettext("failed to join %s: %s\n"),
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
510 jdi.domain_name, xlate_nt_status(status));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
511 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
512 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
513
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
514 (void) printf(gettext("Successfully joined %s\n"), jdi.domain_name);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
515 smbadm_restart_service();
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
516 return (0);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
517 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
518
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
519 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
520 * Domains comprise a centrally administered group of computers and accounts
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
521 * that share a common security and administration policy and database.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
522 * Computers must join a domain and become domain members, which requires
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
523 * an administrator level account name.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
524 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
525 * The '+' character is invalid within a username. We allow the password
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
526 * to be appended to the username using '+' as a scripting convenience.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
527 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
528 static int
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
529 smbadm_join_domain(const char *domain, const char *username)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
530 {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
531 smb_joininfo_t jdi;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
532 uint32_t status;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
533 char *prompt;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
534 char *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
535 int len;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
536
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
537 bzero(&jdi, sizeof (jdi));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
538 jdi.mode = SMB_SECMODE_DOMAIN;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
539 (void) strlcpy(jdi.domain_name, domain, sizeof (jdi.domain_name));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
540 (void) strtrim(jdi.domain_name, " \t\n");
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
541
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
542 if (!smbadm_valid_domainname(jdi.domain_name)) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
543 (void) fprintf(stderr, gettext("domain name is invalid\n"));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
544 smbadm_usage(B_FALSE);
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
545 }
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
546
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
547 if (!smbadm_join_prompt(jdi.domain_name))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
548 return (0);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
549
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
550 if ((p = strchr(username, '+')) != NULL) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
551 ++p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
552
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
553 len = (int)(p - username);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
554 if (len > sizeof (jdi.domain_name))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
555 len = sizeof (jdi.domain_name);
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
556
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
557 (void) strlcpy(jdi.domain_username, username, len);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
558 (void) strlcpy(jdi.domain_passwd, p,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
559 sizeof (jdi.domain_passwd));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
560 } else {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
561 (void) strlcpy(jdi.domain_username, username,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
562 sizeof (jdi.domain_username));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
563 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
564
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
565 if (!smbadm_valid_username(jdi.domain_username)) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
566 (void) fprintf(stderr,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
567 gettext("username contains invalid characters\n"));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
568 smbadm_usage(B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
569 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
570
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
571 if (*jdi.domain_passwd == '\0') {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
572 prompt = gettext("Enter domain password: ");
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
573
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
574 if ((p = getpassphrase(prompt)) == NULL) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
575 (void) fprintf(stderr, gettext("missing password\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
576 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
577 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
578
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
579 (void) strlcpy(jdi.domain_passwd, p,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
580 sizeof (jdi.domain_passwd));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
581 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
582
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
583 (void) printf(gettext("Joining %s ... this may take a minute ...\n"),
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
584 jdi.domain_name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
585
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
586 status = smb_join(&jdi);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
587
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
588 switch (status) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
589 case NT_STATUS_SUCCESS:
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
590 (void) printf(gettext("Successfully joined %s\n"),
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
591 jdi.domain_name);
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
592 bzero(&jdi, sizeof (jdi));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
593 smbadm_restart_service();
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
594 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
595
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
596 case NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND:
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
597 (void) fprintf(stderr,
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
598 gettext("failed to find any domain controllers for %s\n"),
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
599 jdi.domain_name);
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
600 bzero(&jdi, sizeof (jdi));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
601 return (1);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
602
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
603 default:
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
604 (void) fprintf(stderr, gettext("failed to join %s: %s\n"),
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
605 jdi.domain_name, xlate_nt_status(status));
9021
3b15214a2c50 6794156 ADS messages in syslog on domain join failure are too vague
Alan Wright <amw@Sun.COM>
parents: 8670
diff changeset
606 (void) fprintf(stderr, gettext("Please refer to the system log"
3b15214a2c50 6794156 ADS messages in syslog on domain join failure are too vague
Alan Wright <amw@Sun.COM>
parents: 8670
diff changeset
607 " for more information.\n"));
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
608 bzero(&jdi, sizeof (jdi));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
609 return (1);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
610 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
611 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
612
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
613 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
614 * We want to process the user and domain names as separate strings.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
615 * Check for names of the forms below and separate the components as
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
616 * required.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
617 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
618 * name@domain
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
619 * domain\name
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
620 * domain/name
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
621 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
622 * If we encounter any of the forms above in arg, the @, / or \
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
623 * separator is replaced by \0 and the username and domain pointers
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
624 * are changed to point to the appropriate components (in arg).
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
625 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
626 * If none of the separators are encountered, the username and domain
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
627 * pointers remain unchanged.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
628 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
629 static void
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
630 smbadm_extract_domain(char *arg, char **username, char **domain)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
631 {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
632 char *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
633
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
634 if ((p = strpbrk(arg, "/\\@")) != NULL) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
635 if (*p == '@') {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
636 *p = '\0';
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
637 ++p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
638
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
639 if (strchr(arg, '+') != NULL)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
640 return;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
641
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
642 *domain = p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
643 *username = arg;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
644 } else {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
645 *p = '\0';
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
646 ++p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
647 *username = p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
648 *domain = arg;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
649 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
650 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
651 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
652
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
653 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
654 * Check a domain name for RFC 1035 and 1123 compliance. Domain names may
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
655 * contain alphanumeric characters, hyphens and dots. The first and last
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
656 * character of a label must be alphanumeric. Interior characters may be
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
657 * alphanumeric or hypens.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
658 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
659 * Domain names should not contain underscores but we allow them because
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
660 * Windows names are often in non-compliance with this rule.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
661 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
662 static boolean_t
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
663 smbadm_valid_domainname(const char *domain)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
664 {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
665 boolean_t new_label = B_TRUE;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
666 const char *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
667 char label_terminator;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
668
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
669 if (domain == NULL || *domain == '\0')
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
670 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
671
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
672 label_terminator = *domain;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
673
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
674 for (p = domain; *p != '\0'; ++p) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
675 if (new_label) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
676 if (!isalnum(*p))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
677 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
678 new_label = B_FALSE;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
679 label_terminator = *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
680 continue;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
681 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
682
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
683 if (*p == '.') {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
684 if (!isalnum(label_terminator))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
685 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
686 new_label = B_TRUE;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
687 label_terminator = *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
688 continue;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
689 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
690
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
691 label_terminator = *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
692
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
693 if (isalnum(*p) || *p == '-' || *p == '_')
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
694 continue;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
695
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
696 return (B_FALSE);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
697 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
698
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
699 if (!isalnum(label_terminator))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
700 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
701 return (B_TRUE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
702 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
703
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
704 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
705 * Windows user names cannot contain the following characters
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
706 * or control characters.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
707 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
708 * " / \ [ ] < > + ; , ? * = @
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
709 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
710 static boolean_t
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
711 smbadm_valid_username(const char *username)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
712 {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
713 const char *invalid = "\"/\\[]<>+;,?*=@";
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
714 const char *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
715
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
716 if (username == NULL)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
717 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
718
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
719 if (strpbrk(username, invalid))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
720 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
721
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
722 for (p = username; *p != '\0'; p++) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
723 if (iscntrl(*p))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
724 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
725 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
726
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
727 return (B_TRUE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
728 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
729
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
730 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
731 * A workgroup name can contain 1 to 15 characters but cannot be the same
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
732 * as the NetBIOS name. The name must begin with a letter or number.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
733 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
734 * The name cannot consist entirely of spaces or dots, which is covered
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
735 * by the requirement that the name must begin with an alphanumeric
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
736 * character.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
737 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
738 * The name must not contain any of the following characters or control
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
739 * characters.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
740 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
741 * " / \ [ ] : | < > + = ; , ?
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
742 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
743 static boolean_t
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
744 smbadm_valid_workgroup(const char *workgroup)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
745 {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
746 char netbiosname[NETBIOS_NAME_SZ];
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
747 const char *invalid = "\"/\\[]:|<>+=;,?";
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
748 const char *p;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
749
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
750 if (workgroup == NULL || *workgroup == '\0' || (!isalnum(*workgroup)))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
751 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
752
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
753 if (strlen(workgroup) >= NETBIOS_NAME_SZ)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
754 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
755
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
756 if (smb_getnetbiosname(netbiosname, NETBIOS_NAME_SZ) == 0) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
757 if (utf8_strcasecmp(workgroup, netbiosname) == 0)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
758 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
759 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
760
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
761 if (strpbrk(workgroup, invalid))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
762 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
763
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
764 for (p = workgroup; *p != '\0'; p++) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
765 if (iscntrl(*p))
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
766 return (B_FALSE);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
767 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
768
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
769 return (B_TRUE);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
770 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
771
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
772 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
773 * smbadm_list
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
774 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
775 * Displays current security mode and domain/workgroup name.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
776 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
777 /*ARGSUSED*/
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
778 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
779 smbadm_list(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
780 {
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
781 char domain[MAXHOSTNAMELEN];
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
782 char fqdn[MAXHOSTNAMELEN];
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
783 char srvname[MAXHOSTNAMELEN];
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
784 char modename[16];
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
785 int rc;
8670
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8474
diff changeset
786 smb_inaddr_t srvipaddr;
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
787 char ipstr[INET6_ADDRSTRLEN];
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
788
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
789 rc = smb_config_getstr(SMB_CI_SECURITY, modename, sizeof (modename));
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
790 if (rc != SMBD_SMF_OK) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
791 (void) fprintf(stderr,
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
792 gettext("cannot determine the operational mode\n"));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
793 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
794 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
795
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
796 if (smb_getdomainname(domain, sizeof (domain)) != 0) {
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
797 (void) fprintf(stderr, gettext("failed to get the %s name\n"),
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
798 modename);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
799 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
800 }
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
801
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
802 if (strcmp(modename, "workgroup") == 0) {
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
803 (void) printf(gettext("[*] [%s]\n"), domain);
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
804 return (0);
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
805 }
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
806
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
807 (void) printf(gettext("[*] [%s]\n"), domain);
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
808 if ((smb_getfqdomainname(fqdn, sizeof (fqdn)) == 0) && (*fqdn != '\0'))
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
809 (void) printf(gettext("[*] [%s]\n"), fqdn);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
810
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
811 if ((smb_get_dcinfo(srvname, MAXHOSTNAMELEN, &srvipaddr)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
812 == NT_STATUS_SUCCESS) && (*srvname != '\0') &&
8670
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8474
diff changeset
813 (!smb_inet_iszero(&srvipaddr))) {
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8474
diff changeset
814 (void) smb_inet_ntop(&srvipaddr, ipstr,
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8474
diff changeset
815 SMB_IPSTRLEN(srvipaddr.a_family));
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
816 (void) printf(gettext("\t[+%s.%s] [%s]\n"),
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
817 srvname, fqdn, ipstr);
7348
73b61202d5d6 6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents: 7052
diff changeset
818 }
8474
7803efd2fa77 6559601 Computer Management fails to create or list shares
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
819
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9021
diff changeset
820 smb_domain_show();
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
821 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
822 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
823
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
824 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
825 * smbadm_group_create
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
826 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
827 * Creates a local SMB group
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
828 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
829 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
830 smbadm_group_create(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
831 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
832 char *gname = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
833 char *desc = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
834 char option;
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
835 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
836
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
837 while ((option = getopt(argc, argv, "d:")) != -1) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
838 switch (option) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
839 case 'd':
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
840 desc = optarg;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
841 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
842
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
843 default:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
844 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
845 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
846 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
847
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
848 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
849 if (optind >= argc || gname == NULL || *gname == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
850 (void) fprintf(stderr, gettext("missing group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
851 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
852 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
853
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
854 if (getgrnam(gname) == NULL) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
855 (void) fprintf(stderr,
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
856 gettext("failed to get the Solaris group '%s'\n"), gname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
857 (void) fprintf(stderr,
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
858 gettext("use 'groupadd' to add '%s'\n"), gname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
859 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
860 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
861
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
862 status = smb_lgrp_add(gname, desc);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
863 if (status != SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
864 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
865 gettext("failed to create the group (%s)\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
866 smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
867 } else {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
868 (void) printf(gettext("'%s' created.\n"),
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
869 gname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
870 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
871
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
872 return (status);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
873 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
874
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
875 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
876 * smbadm_group_dump_members
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
877 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
878 * Dump group members details.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
879 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
880 static void
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
881 smbadm_group_dump_members(smb_gsid_t *members, int num)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
882 {
6432
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
883 char sidstr[SMB_SID_STRSZ];
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
884 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
885
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
886 if (num == 0) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
887 (void) printf(gettext("\tNo members\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
888 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
889 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
890
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
891 (void) printf(gettext("\tMembers:\n"));
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
892 for (i = 0; i < num; i++) {
6600
4e63bcd27ae9 6473755 RFE: Need ability to reconcile oplock and delegation conflicts
as200622
parents: 6432
diff changeset
893 *sidstr = '\0';
4e63bcd27ae9 6473755 RFE: Need ability to reconcile oplock and delegation conflicts
as200622
parents: 6432
diff changeset
894 if (smb_lookup_sid(members[i].gs_sid, sidstr,
4e63bcd27ae9 6473755 RFE: Need ability to reconcile oplock and delegation conflicts
as200622
parents: 6432
diff changeset
895 sizeof (sidstr)) == NT_STATUS_SUCCESS)
4e63bcd27ae9 6473755 RFE: Need ability to reconcile oplock and delegation conflicts
as200622
parents: 6432
diff changeset
896 (void) printf(gettext("\t\t%s\n"), sidstr);
4e63bcd27ae9 6473755 RFE: Need ability to reconcile oplock and delegation conflicts
as200622
parents: 6432
diff changeset
897 else
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
898 (void) printf(gettext("\t\tinvalid SID\n"));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
899 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
900 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
901
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
902 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
903 * smbadm_group_dump_privs
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
904 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
905 * Dump group privilege details.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
906 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
907 static void
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
908 smbadm_group_dump_privs(smb_privset_t *privs)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
909 {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
910 smb_privinfo_t *pinfo;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
911 char *pstatus;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
912 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
913
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
914 (void) printf(gettext("\tPrivileges: \n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
915
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
916 for (i = 0; i < privs->priv_cnt; i++) {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
917 pinfo = smb_priv_getbyvalue(privs->priv[i].luid.lo_part);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
918 if ((pinfo == NULL) || (pinfo->flags & PF_PRESENTABLE) == 0)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
919 continue;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
920
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
921 switch (privs->priv[i].attrs) {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
922 case SE_PRIVILEGE_ENABLED:
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
923 pstatus = "On";
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
924 break;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
925 case SE_PRIVILEGE_DISABLED:
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
926 pstatus = "Off";
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
927 break;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
928 default:
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
929 pstatus = "Unknown";
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
930 break;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
931 }
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
932 (void) printf(gettext("\t\t%s: %s\n"), pinfo->name, pstatus);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
933 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
934
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
935 if (privs->priv_cnt == 0)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
936 (void) printf(gettext("\t\tNo privileges\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
937 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
938
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
939 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
940 * smbadm_group_dump
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
941 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
942 * Dump group details.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
943 */
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
944 static void
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
945 smbadm_group_dump(smb_group_t *grp, boolean_t show_mem, boolean_t show_privs)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
946 {
6432
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
947 char sidstr[SMB_SID_STRSZ];
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
948
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
949 (void) printf(gettext("%s (%s)\n"), grp->sg_name, grp->sg_cmnt);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
950
6432
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
951 smb_sid_tostr(grp->sg_id.gs_sid, sidstr);
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
952 (void) printf(gettext("\tSID: %s\n"), sidstr);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
953
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
954 if (show_privs)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
955 smbadm_group_dump_privs(grp->sg_privs);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
956
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
957 if (show_mem)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
958 smbadm_group_dump_members(grp->sg_members, grp->sg_nmembers);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
959 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
960
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
961 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
962 * smbadm_group_show
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
963 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
964 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
965 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
966 smbadm_group_show(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
967 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
968 char *gname = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
969 boolean_t show_privs;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
970 boolean_t show_members;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
971 char option;
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
972 int status;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
973 smb_group_t grp;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
974 smb_giter_t gi;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
975
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
976 show_privs = show_members = B_FALSE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
977
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
978 while ((option = getopt(argc, argv, "mp")) != -1) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
979 switch (option) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
980 case 'm':
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
981 show_members = B_TRUE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
982 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
983 case 'p':
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
984 show_privs = B_TRUE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
985 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
986
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
987 default:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
988 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
989 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
990 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
991
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
992 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
993 if (optind >= argc || gname == NULL || *gname == '\0')
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
994 gname = "*";
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
995
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
996 if (strcmp(gname, "*")) {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
997 status = smb_lgrp_getbyname(gname, &grp);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
998 if (status == SMB_LGRP_SUCCESS) {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
999 smbadm_group_dump(&grp, show_members, show_privs);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1000 smb_lgrp_free(&grp);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1001 } else {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1002 (void) fprintf(stderr,
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1003 gettext("failed to find %s (%s)\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1004 gname, smb_lgrp_strerror(status));
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1005 }
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1006 return (status);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1007 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1008
6432
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1009 if ((status = smb_lgrp_iteropen(&gi)) != SMB_LGRP_SUCCESS) {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1010 (void) fprintf(stderr, gettext("failed to list groups (%s)\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1011 smb_lgrp_strerror(status));
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1012 return (status);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1013 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1014
6432
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1015 while ((status = smb_lgrp_iterate(&gi, &grp)) == SMB_LGRP_SUCCESS) {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1016 smbadm_group_dump(&grp, show_members, show_privs);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1017 smb_lgrp_free(&grp);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1018 }
6432
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1019
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1020 smb_lgrp_iterclose(&gi);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1021
6432
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1022 if (status != SMB_LGRP_NO_MORE) {
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1023 (void) fprintf(stderr,
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1024 gettext("failed to get all the groups (%s)\n"),
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1025 smb_lgrp_strerror(status));
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1026 return (status);
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1027 }
98715880dd9e 6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents: 6139
diff changeset
1028
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1029 return (0);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1030 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1031
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1032 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1033 * smbadm_group_delete
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1034 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1035 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1036 smbadm_group_delete(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1037 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1038 char *gname = NULL;
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1039 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1040
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1041 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1042 if (optind >= argc || gname == NULL || *gname == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1043 (void) fprintf(stderr, gettext("missing group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1044 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1045 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1046
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1047 status = smb_lgrp_delete(gname);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1048 if (status != SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1049 (void) fprintf(stderr,
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1050 gettext("failed to delete %s (%s)\n"), gname,
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1051 smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1052 } else {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1053 (void) printf(gettext("%s deleted.\n"), gname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1054 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1055
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1056 return (status);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1057 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1058
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1059 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1060 * smbadm_group_rename
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1061 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1062 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1063 smbadm_group_rename(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1064 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1065 char *gname = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1066 char *ngname = NULL;
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1067 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1068
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1069 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1070 if (optind++ >= argc || gname == NULL || *gname == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1071 (void) fprintf(stderr, gettext("missing group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1072 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1073 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1074
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1075 ngname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1076 if (optind >= argc || ngname == NULL || *ngname == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1077 (void) fprintf(stderr, gettext("missing new group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1078 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1079 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1080
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1081 if (getgrnam(ngname) == NULL) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1082 (void) fprintf(stderr,
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1083 gettext("failed to get the Solaris group '%s'\n"), ngname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1084 (void) fprintf(stderr,
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1085 gettext("use 'groupadd' to add '%s'\n"), ngname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1086 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1087 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1088
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1089 status = smb_lgrp_rename(gname, ngname);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1090 if (status != SMB_LGRP_SUCCESS) {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1091 if (status == SMB_LGRP_EXISTS)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1092 (void) fprintf(stderr,
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1093 gettext("failed to rename '%s' (%s already "
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1094 "exists)\n"), gname, ngname);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1095 else
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1096 (void) fprintf(stderr,
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1097 gettext("failed to rename '%s' (%s)\n"), gname,
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1098 smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1099 } else {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1100 (void) printf(gettext("'%s' renamed to '%s'\n"), gname, ngname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1101 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1102
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1103 return (status);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1104 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1105
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1106 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1107 * smbadm_group_setprop
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1108 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1109 * Set the group properties.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1110 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1111 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1112 smbadm_group_setprop(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1113 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1114 char *gname = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1115 smbadm_prop_t props[SMBADM_NPROP];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1116 smbadm_prop_handle_t *phandle;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1117 char option;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1118 int pcnt = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1119 int ret;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1120 int p;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1121
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1122 bzero(props, SMBADM_NPROP * sizeof (smbadm_prop_t));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1123
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1124 while ((option = getopt(argc, argv, "p:")) != -1) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1125 switch (option) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1126 case 'p':
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1127 if (pcnt >= SMBADM_NPROP) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1128 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1129 gettext("exceeded number of supported"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1130 " properties\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1131 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1132 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1133
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1134 if (smbadm_prop_parse(optarg, &props[pcnt++]) != 0)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1135 smbadm_usage(B_FALSE);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1136 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1137
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1138 default:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1139 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1140 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1141 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1142
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1143 if (pcnt == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1144 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1145 gettext("missing property=value argument\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1146 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1147 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1148
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1149 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1150 if (optind >= argc || gname == NULL || *gname == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1151 (void) fprintf(stderr, gettext("missing group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1152 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1153 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1154
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1155 for (p = 0; p < pcnt; p++) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1156 phandle = smbadm_prop_gethandle(props[p].p_name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1157 if (phandle) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1158 if (phandle->p_setfn(gname, &props[p]) != 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1159 ret = 1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1160 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1161 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1162
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1163 return (ret);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1164 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1165
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1166 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1167 * smbadm_group_getprop
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1168 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1169 * Get the group properties.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1170 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1171 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1172 smbadm_group_getprop(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1173 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1174 char *gname = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1175 smbadm_prop_t props[SMBADM_NPROP];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1176 smbadm_prop_handle_t *phandle;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1177 char option;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1178 int pcnt = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1179 int ret;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1180 int p;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1181
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1182 bzero(props, SMBADM_NPROP * sizeof (smbadm_prop_t));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1183
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1184 while ((option = getopt(argc, argv, "p:")) != -1) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1185 switch (option) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1186 case 'p':
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1187 if (pcnt >= SMBADM_NPROP) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1188 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1189 gettext("exceeded number of supported"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1190 " properties\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1191 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1192 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1193
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1194 if (smbadm_prop_parse(optarg, &props[pcnt++]) != 0)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1195 smbadm_usage(B_FALSE);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1196 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1197
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1198 default:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1199 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1200 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1201 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1202
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1203 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1204 if (optind >= argc || gname == NULL || *gname == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1205 (void) fprintf(stderr, gettext("missing group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1206 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1207 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1208
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1209 if (pcnt == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1210 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1211 * If no property has be specified then get
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1212 * all the properties.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1213 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1214 pcnt = SMBADM_NPROP;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1215 for (p = 0; p < pcnt; p++)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1216 props[p].p_name = smbadm_ptable[p].p_name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1217 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1218
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1219 for (p = 0; p < pcnt; p++) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1220 phandle = smbadm_prop_gethandle(props[p].p_name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1221 if (phandle) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1222 if (phandle->p_getfn(gname, &props[p]) != 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1223 ret = 1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1224 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1225 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1226
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1227 return (ret);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1228 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1229
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1230 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1231 * smbadm_group_addmember
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1232 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1233 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1234 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1235 smbadm_group_addmember(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1236 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1237 char *gname = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1238 char **mname;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1239 char option;
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1240 smb_gsid_t msid;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1241 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1242 int mcnt = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1243 int ret = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1244 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1245
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1246
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1247 mname = (char **)malloc(argc * sizeof (char *));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1248 if (mname == NULL) {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1249 warn(gettext("failed to add group member"));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1250 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1251 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1252 bzero(mname, argc * sizeof (char *));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1253
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1254 while ((option = getopt(argc, argv, "m:")) != -1) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1255 switch (option) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1256 case 'm':
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1257 mname[mcnt++] = optarg;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1258 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1259
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1260 default:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1261 free(mname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1262 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1263 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1264 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1265
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1266 if (mcnt == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1267 (void) fprintf(stderr, gettext("missing member name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1268 free(mname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1269 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1270 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1271
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1272 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1273 if (optind >= argc || gname == NULL || *gname == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1274 (void) fprintf(stderr, gettext("missing group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1275 free(mname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1276 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1277 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1278
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1279
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1280 for (i = 0; i < mcnt; i++) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1281 if (mname[i] == NULL)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1282 continue;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1283
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1284 if (smb_lookup_name(mname[i], &msid) != NT_STATUS_SUCCESS) {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1285 (void) fprintf(stderr,
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1286 gettext("failed to add %s: unable to obtain SID\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1287 mname[i]);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1288 continue;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1289 }
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1290
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1291 status = smb_lgrp_add_member(gname, msid.gs_sid, msid.gs_type);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1292 free(msid.gs_sid);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1293 if (status != SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1294 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1295 gettext("failed to add %s (%s)\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1296 mname[i], smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1297 ret = 1;
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1298 } else {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1299 (void) printf(gettext("'%s' is now a member of '%s'\n"),
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1300 mname[i], gname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1301 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1302 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1303
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1304 free(mname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1305 return (ret);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1306 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1307
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1308 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1309 * smbadm_group_delmember
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1310 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1311 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1312 smbadm_group_delmember(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1313 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1314 char *gname = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1315 char **mname;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1316 char option;
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1317 smb_gsid_t msid;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1318 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1319 int mcnt = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1320 int ret = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1321 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1322
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1323 mname = (char **)malloc(argc * sizeof (char *));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1324 if (mname == NULL) {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1325 warn(gettext("failed to delete group member"));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1326 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1327 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1328 bzero(mname, argc * sizeof (char *));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1329
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1330 while ((option = getopt(argc, argv, "m:")) != -1) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1331 switch (option) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1332 case 'm':
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1333 mname[mcnt++] = optarg;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1334 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1335
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1336 default:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1337 free(mname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1338 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1339 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1340 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1341
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1342 if (mcnt == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1343 (void) fprintf(stderr, gettext("missing member name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1344 free(mname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1345 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1346 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1347
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1348 gname = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1349 if (optind >= argc || gname == NULL || *gname == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1350 (void) fprintf(stderr, gettext("missing group name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1351 free(mname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1352 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1353 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1354
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1355
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1356 for (i = 0; i < mcnt; i++) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1357 if (mname[i] == NULL)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1358 continue;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1359
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1360 if (smb_lookup_name(mname[i], &msid) != NT_STATUS_SUCCESS) {
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1361 (void) fprintf(stderr,
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1362 gettext("failed to remove %s: "
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1363 "unable to obtain SID\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1364 mname[i]);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1365 continue;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1366 }
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1367
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1368 status = smb_lgrp_del_member(gname, msid.gs_sid, msid.gs_type);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1369 free(msid.gs_sid);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1370 if (status != SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1371 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1372 gettext("failed to remove %s (%s)\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1373 mname[i], smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1374 ret = 1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1375 } else {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1376 (void) printf(
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1377 gettext("'%s' has been removed from %s\n"),
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1378 mname[i], gname);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1379 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1380 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1381
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1382 return (ret);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1383 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1384
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1385 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1386 smbadm_user_disable(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1387 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1388 int error;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1389 char *user = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1390
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1391 user = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1392 if (optind >= argc || user == NULL || *user == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1393 (void) fprintf(stderr, gettext("missing user name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1394 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1395 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1396
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1397 error = smb_pwd_setcntl(user, SMB_PWC_DISABLE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1398 if (error == SMB_PWE_SUCCESS)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1399 (void) printf(gettext("%s is disabled.\n"), user);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1400 else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1401 (void) fprintf(stderr, "%s\n", smbadm_pwd_strerror(error));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1402
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1403 return (error);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1404 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1405
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1406 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1407 smbadm_user_enable(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1408 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1409 int error;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1410 char *user = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1411
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1412 user = argv[optind];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1413 if (optind >= argc || user == NULL || *user == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1414 (void) fprintf(stderr, gettext("missing user name\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1415 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1416 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1417
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1418 error = smb_pwd_setcntl(user, SMB_PWC_ENABLE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1419 if (error == SMB_PWE_SUCCESS)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1420 (void) printf(gettext("%s is enabled.\n"), user);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1421 else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1422 (void) fprintf(stderr, "%s\n", smbadm_pwd_strerror(error));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1423
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1424 return (error);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1425 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1426
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1427
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1428 int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1429 main(int argc, char **argv)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1430 {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1431 int ret;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1432 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1433
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1434 (void) malloc(0); /* satisfy libumem dependency */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1435
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1436 progname = basename(argv[0]);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1437
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1438 if (getzoneid() != GLOBAL_ZONEID) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1439 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1440 gettext("cannot execute in non-global zone\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1441 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1442 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1443
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1444 if (is_system_labeled()) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1445 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1446 gettext("Trusted Extensions not supported\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1447 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1448 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1449
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1450 if (argc < 2) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1451 (void) fprintf(stderr, gettext("missing command\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1452 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1453 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1454
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1455 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1456 * Special case "cmd --help/-?"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1457 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1458 if (strcmp(argv[1], "-?") == 0 ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1459 strcmp(argv[1], "--help") == 0 ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1460 strcmp(argv[1], "-h") == 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1461 smbadm_usage(B_TRUE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1462
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1463 for (i = 0; i < SMBADM_NCMD; ++i) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1464 curcmd = &smbadm_cmdtable[i];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1465 if (strcasecmp(argv[1], curcmd->name) == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1466 if (argc > 2) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1467 /* cmd subcmd --help/-? */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1468 if (strcmp(argv[2], "-?") == 0 ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1469 strcmp(argv[2], "--help") == 0 ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1470 strcmp(argv[2], "-h") == 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1471 smbadm_usage(B_TRUE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1472 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1473
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1474 if ((ret = smbadm_init()) != 0)
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1475 return (ret);
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1476
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1477 ret = curcmd->func(argc - 1, &argv[1]);
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1478
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1479 smbadm_fini();
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1480 return (ret);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1481 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1482 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1483
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1484 curcmd = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1485 (void) fprintf(stderr, gettext("unknown subcommand (%s)\n"), argv[1]);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1486 smbadm_usage(B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1487 return (2);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1488 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1489
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1490 static int
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1491 smbadm_init(void)
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1492 {
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1493 int rc;
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1494
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1495 switch (curcmd->flags & SMBADM_CMDF_TYPEMASK) {
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1496 case SMBADM_CMDF_GROUP:
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1497 if (smb_idmap_start() != 0) {
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1498 (void) fprintf(stderr,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1499 gettext("failed to contact idmap service\n"));
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1500 return (1);
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1501 }
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1502
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1503 if ((rc = smb_lgrp_start()) != SMB_LGRP_SUCCESS) {
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1504 (void) fprintf(stderr,
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1505 gettext("failed to initialize (%s)\n"),
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1506 smb_lgrp_strerror(rc));
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1507 smb_idmap_stop();
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1508 return (1);
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1509 }
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1510 break;
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1511
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1512 case SMBADM_CMDF_USER:
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1513 smb_pwd_init(B_FALSE);
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1514 break;
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1515
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1516 default:
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1517 break;
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1518 }
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1519
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1520 return (0);
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1521 }
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1522
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1523 static void
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1524 smbadm_fini(void)
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1525 {
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1526 switch (curcmd->flags & SMBADM_CMDF_TYPEMASK) {
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1527 case SMBADM_CMDF_GROUP:
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1528 smb_lgrp_stop();
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1529 smb_idmap_stop();
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1530 break;
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1531
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1532 case SMBADM_CMDF_USER:
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1533 smb_pwd_fini();
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1534 break;
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1535
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1536 default:
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1537 break;
6139
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1538 }
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1539 }
5c743b207bf9 6541120 Configuration is not propagated to SMB kernel module
jb150015
parents: 5772
diff changeset
1540
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1541 static boolean_t
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1542 smbadm_prop_validate(smbadm_prop_t *prop, boolean_t chkval)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1543 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1544 smbadm_prop_handle_t *pinfo;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1545 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1546
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1547 for (i = 0; i < SMBADM_NPROP; i++) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1548 pinfo = &smbadm_ptable[i];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1549 if (strcmp(pinfo->p_name, prop->p_name) == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1550 if (pinfo->p_chkfn && chkval)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1551 return (pinfo->p_chkfn(prop));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1552
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1553 return (B_TRUE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1554 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1555 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1556
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1557 (void) fprintf(stderr, gettext("unrecognized property '%s'\n"),
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1558 prop->p_name);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1559
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1560 return (B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1561 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1562
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1563 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1564 smbadm_prop_parse(char *arg, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1565 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1566 boolean_t parse_value;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1567 char *equal;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1568
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1569 if (arg == NULL)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1570 return (2);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1571
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1572 prop->p_name = prop->p_value = NULL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1573
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1574 if (strcmp(curcmd->name, "set") == 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1575 parse_value = B_TRUE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1576 else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1577 parse_value = B_FALSE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1578
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1579 prop->p_name = arg;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1580
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1581 if (parse_value) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1582 equal = strchr(arg, '=');
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1583 if (equal == NULL)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1584 return (2);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1585
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1586 *equal++ = '\0';
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1587 prop->p_value = equal;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1588 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1589
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1590 if (smbadm_prop_validate(prop, parse_value) == B_FALSE)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1591 return (2);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1592
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1593 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1594 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1595
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1596 static smbadm_prop_handle_t *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1597 smbadm_prop_gethandle(char *pname)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1598 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1599 int i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1600
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1601 for (i = 0; i < SMBADM_NPROP; i++)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1602 if (strcmp(pname, smbadm_ptable[i].p_name) == 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1603 return (&smbadm_ptable[i]);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1604
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1605 return (NULL);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1606 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1607
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1608 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1609 smbadm_setprop_desc(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1610 {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1611 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1612
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1613 status = smb_lgrp_setcmnt(gname, prop->p_value);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1614 if (status != SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1615 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1616 gettext("failed to modify the group description (%s)\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1617 smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1618 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1619 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1620
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1621 (void) printf(gettext("%s: description modified\n"), gname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1622 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1623 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1624
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1625 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1626 smbadm_getprop_desc(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1627 {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1628 char *cmnt = NULL;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1629 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1630
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1631 status = smb_lgrp_getcmnt(gname, &cmnt);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1632 if (status != SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1633 (void) fprintf(stderr,
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1634 gettext("failed to get the group description (%s)\n"),
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1635 smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1636 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1637 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1638
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1639 (void) printf(gettext("\t%s: %s\n"), prop->p_name, cmnt);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1640 free(cmnt);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1641 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1642 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1643
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1644 static int
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1645 smbadm_group_setpriv(char *gname, uint8_t priv_id, smbadm_prop_t *prop)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1646 {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1647 boolean_t enable;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1648 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1649 int ret;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1650
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1651 if (strcasecmp(prop->p_value, "on") == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1652 (void) printf(gettext("Enabling %s privilege "), prop->p_name);
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1653 enable = B_TRUE;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1654 } else {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1655 (void) printf(gettext("Disabling %s privilege "), prop->p_name);
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1656 enable = B_FALSE;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1657 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1658
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1659 status = smb_lgrp_setpriv(gname, priv_id, enable);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1660 if (status == SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1661 (void) printf(gettext("succeeded\n"));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1662 ret = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1663 } else {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1664 (void) printf(gettext("failed: %s\n"),
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1665 smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1666 ret = 1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1667 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1668
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1669 return (ret);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1670 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1671
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1672 static int
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1673 smbadm_group_getpriv(char *gname, uint8_t priv_id, smbadm_prop_t *prop)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1674 {
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1675 boolean_t enable;
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1676 int status;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1677
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1678 status = smb_lgrp_getpriv(gname, priv_id, &enable);
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1679 if (status != SMB_LGRP_SUCCESS) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1680 (void) fprintf(stderr, gettext("failed to get %s (%s)\n"),
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1681 prop->p_name, smb_lgrp_strerror(status));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1682 return (1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1683 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1684
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1685 (void) printf(gettext("\t%s: %s\n"), prop->p_name,
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5521
diff changeset
1686 (enable) ? "On" : "Off");
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1687
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1688 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1689 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1690
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1691 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1692 smbadm_setprop_tkowner(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1693 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1694 return (smbadm_group_setpriv(gname, SE_TAKE_OWNERSHIP_LUID, prop));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1695 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1696
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1697 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1698 smbadm_getprop_tkowner(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1699 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1700 return (smbadm_group_getpriv(gname, SE_TAKE_OWNERSHIP_LUID, prop));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1701 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1702
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1703 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1704 smbadm_setprop_backup(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1705 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1706 return (smbadm_group_setpriv(gname, SE_BACKUP_LUID, prop));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1707 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1708
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1709 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1710 smbadm_getprop_backup(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1711 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1712 return (smbadm_group_getpriv(gname, SE_BACKUP_LUID, prop));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1713 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1714
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1715 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1716 smbadm_setprop_restore(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1717 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1718 return (smbadm_group_setpriv(gname, SE_RESTORE_LUID, prop));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1719 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1720
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1721 static int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1722 smbadm_getprop_restore(char *gname, smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1723 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1724 return (smbadm_group_getpriv(gname, SE_RESTORE_LUID, prop));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1725 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1726
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1727 static boolean_t
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1728 smbadm_chkprop_priv(smbadm_prop_t *prop)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1729 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1730 if (prop->p_value == NULL || *prop->p_value == '\0') {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1731 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1732 gettext("missing value for '%s'\n"), prop->p_name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1733 return (B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1734 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1735
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1736 if (strcasecmp(prop->p_value, "on") == 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1737 return (B_TRUE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1738
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1739 if (strcasecmp(prop->p_value, "off") == 0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1740 return (B_TRUE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1741
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1742 (void) fprintf(stderr,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1743 gettext("%s: unrecognized value for '%s' property\n"),
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1744 prop->p_value, prop->p_name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1745
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1746 return (B_FALSE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1747 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1748
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1749 static const char *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1750 smbadm_pwd_strerror(int error)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1751 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1752 switch (error) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1753 case SMB_PWE_SUCCESS:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1754 return (gettext("Success."));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1755
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1756 case SMB_PWE_USER_UNKNOWN:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1757 return (gettext("User does not exist."));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1758
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1759 case SMB_PWE_USER_DISABLE:
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 7588
diff changeset
1760 return (gettext("User is disabled."));
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1761
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1762 case SMB_PWE_CLOSE_FAILED:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1763 case SMB_PWE_OPEN_FAILED:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1764 case SMB_PWE_WRITE_FAILED:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1765 case SMB_PWE_UPDATE_FAILED:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1766 return (gettext("Unexpected failure. "
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1767 "SMB password database unchanged."));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1768
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1769 case SMB_PWE_STAT_FAILED:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1770 return (gettext("stat of SMB password file failed."));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1771
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1772 case SMB_PWE_BUSY:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1773 return (gettext("SMB password database busy. "
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1774 "Try again later."));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1775
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1776 case SMB_PWE_DENIED:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1777 return (gettext("Operation not permitted."));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1778
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1779 case SMB_PWE_SYSTEM_ERROR:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1780 return (gettext("System error."));
7052
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1781
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1782 default:
efa04b030974 6615409 Rename appropriate structures in userland
amw
parents: 6600
diff changeset
1783 break;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1784 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1785
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1786 return (gettext("Unknown error code."));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1787 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1788
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1789 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1790 * Enable libumem debugging by default on DEBUG builds.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1791 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1792 #ifdef DEBUG
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1793 const char *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1794 _umem_debug_init(void)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1795 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1796 return ("default,verbose"); /* $UMEM_DEBUG setting */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1797 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1798
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1799 const char *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1800 _umem_logging_init(void)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1801 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1802 return ("fail,contents"); /* $UMEM_LOGGING setting */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1803 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1804 #endif