svn commit: samba r16953 - branches/SAMBA_3_0/source/rpc_server
trunk/source/rpc_server
jerry at samba.org
jerry at samba.org
Tue Jul 11 20:02:23 GMT 2006
Author: jerry
Date: 2006-07-11 20:02:22 +0000 (Tue, 11 Jul 2006)
New Revision: 16953
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16953
Log:
Don't allow groups to be renamed to an existing user or other group
Modified:
branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c
trunk/source/rpc_server/srv_samr_nt.c
Changeset:
Modified: branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c 2006-07-11 18:45:22 UTC (rev 16952)
+++ branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c 2006-07-11 20:02:22 UTC (rev 16953)
@@ -4590,6 +4590,10 @@
switch (ctr->level) {
case 2:
+ {
+ fstring group_name;
+ enum SID_NAME_USE type;
+
/* We currently do not support renaming groups in the
the BUILTIN domain. Refer to util_builtin.c to understand
why. The eventually needs to be fixed to be like Windows
@@ -4599,13 +4603,26 @@
return NT_STATUS_SPECIAL_ACCOUNT;
}
- if ( ctr->alias.info2.name.string ) {
- unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string,
- sizeof(info.acct_name)-1 );
+ /* There has to be a valid name */
+ if ( !ctr->alias.info2.name.string )
+ return NT_STATUS_INVALID_PARAMETER;
+
+ unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string,
+ sizeof(info.acct_name)-1 );
+
+ /* make sure the name doesn't already exist as a user
+ or local group */
+
+ fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name );
+ if ( lookup_name( p->mem_ctx, group_name, 0, NULL, NULL, NULL, &type) ) {
+ if ( type == SID_NAME_USER ) {
+ return NT_STATUS_USER_EXISTS;
+ }
+
+ return NT_STATUS_ALIAS_EXISTS;
}
- else
- fstrcpy( info.acct_name, "" );
break;
+ }
case 3:
if ( ctr->alias.info3.description.string ) {
unistr2_to_ascii( info.acct_desc,
Modified: trunk/source/rpc_server/srv_samr_nt.c
===================================================================
--- trunk/source/rpc_server/srv_samr_nt.c 2006-07-11 18:45:22 UTC (rev 16952)
+++ trunk/source/rpc_server/srv_samr_nt.c 2006-07-11 20:02:22 UTC (rev 16953)
@@ -4590,6 +4590,10 @@
switch (ctr->level) {
case 2:
+ {
+ fstring group_name;
+ enum SID_NAME_USE type;
+
/* We currently do not support renaming groups in the
the BUILTIN domain. Refer to util_builtin.c to understand
why. The eventually needs to be fixed to be like Windows
@@ -4599,13 +4603,26 @@
return NT_STATUS_SPECIAL_ACCOUNT;
}
- if ( ctr->alias.info2.name.string ) {
- unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string,
- sizeof(info.acct_name)-1 );
+ /* There has to be a valid name */
+ if ( !ctr->alias.info2.name.string )
+ return NT_STATUS_INVALID_PARAMETER;
+
+ unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string,
+ sizeof(info.acct_name)-1 );
+
+ /* make sure the name doesn't already exist as a user
+ or local group */
+
+ fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name );
+ if ( lookup_name( p->mem_ctx, group_name, 0, NULL, NULL, NULL, &type) ) {
+ if ( type == SID_NAME_USER ) {
+ return NT_STATUS_USER_EXISTS;
+ }
+
+ return NT_STATUS_ALIAS_EXISTS;
}
- else
- fstrcpy( info.acct_name, "" );
break;
+ }
case 3:
if ( ctr->alias.info3.description.string ) {
unistr2_to_ascii( info.acct_desc,
More information about the samba-cvs
mailing list