summaryrefslogtreecommitdiff
path: root/source/rpc_server
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-10-11 09:35:01 +0000
committerJeremy Allison <jra@samba.org>2001-10-11 09:35:01 +0000
commitf0b5382869d12249e593ac2f10fc9f1f9d03bae6 (patch)
tree97543b143f7e42dfdfd7e6e46ad22d0fd59bcdab /source/rpc_server
parent8d4870bccd026d059c160de3642bb427338256ec (diff)
downloadsamba-f0b5382869d12249e593ac2f10fc9f1f9d03bae6.tar.gz
Sync-up with SAMBA_2_2 branch.
Jeremy.
Diffstat (limited to 'source/rpc_server')
-rw-r--r--source/rpc_server/srv_dfs_nt.c45
-rw-r--r--source/rpc_server/srv_lsa_nt.c24
-rw-r--r--source/rpc_server/srv_netlog_nt.c280
-rw-r--r--source/rpc_server/srv_pipe.c51
-rw-r--r--source/rpc_server/srv_pipe_hnd.c11
-rw-r--r--source/rpc_server/srv_reg_nt.c8
-rw-r--r--source/rpc_server/srv_samr_nt.c1109
-rwxr-xr-xsource/rpc_server/srv_spoolss.c2
-rw-r--r--source/rpc_server/srv_spoolss_nt.c701
-rw-r--r--source/rpc_server/srv_srvsvc_nt.c177
-rw-r--r--source/rpc_server/srv_util.c33
-rw-r--r--source/rpc_server/srv_wkssvc_nt.c2
12 files changed, 1329 insertions, 1114 deletions
diff --git a/source/rpc_server/srv_dfs_nt.c b/source/rpc_server/srv_dfs_nt.c
index 54c3fbf324c..9bc12e2a965 100644
--- a/source/rpc_server/srv_dfs_nt.c
+++ b/source/rpc_server/srv_dfs_nt.c
@@ -56,7 +56,11 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u)
if (user.uid != 0) {
DEBUG(10,("_dfs_add: uid != 0. Access denied.\n"));
- return ERROR_ACCESS_DENIED;
+
+ /* RPC calls return Windows errors. NT_STATUS_ACCESS_DENIED
+ doesn't work as a return code for RPC calls
+ */
+ return ERRnoaccess;
}
unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1);
@@ -70,10 +74,7 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u)
pstrcat(altpath, "\\");
pstrcat(altpath, sharename);
- if(!create_junction(dfspath, &jn))
- return NERR_DfsNoSuchServer;
-
- if(get_referred_path(&jn))
+ if(get_referred_path(dfspath, &jn, NULL, NULL))
{
exists = True;
jn.referral_count += 1;
@@ -106,7 +107,7 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u)
if(!create_msdfs_link(&jn, exists))
return NERR_DfsCantCreateJunctionPoint;
- return NT_STATUS_NOPROBLEMO;
+ return ERRsuccess;
}
uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u)
@@ -122,7 +123,10 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u
if (user.uid != 0) {
DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n"));
- return ERROR_ACCESS_DENIED;
+ /* NT_STATUS_ACCESS_DENIED will not work as a status code
+ for RPC calls
+ */
+ return ERRnoaccess;
}
unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1);
@@ -137,16 +141,14 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u
pstrcpy(altpath, servername);
pstrcat(altpath, "\\");
pstrcat(altpath, sharename);
+ strlower(altpath);
}
DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n",
dfspath, servername, sharename));
- if(!create_junction(dfspath, &jn))
- return NERR_DfsNoSuchServer;
-
- if(!get_referred_path(&jn))
- return NERR_DfsNoSuchVolume;
+ if(!get_referred_path(dfspath, &jn, NULL, NULL))
+ return NERR_DfsNoSuchVolume;
/* if no server-share pair given, remove the msdfs link completely */
if(!q_u->ptr_ServerName && !q_u->ptr_ShareName)
@@ -158,14 +160,18 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u
{
int i=0;
/* compare each referral in the list with the one to remove */
+ DEBUG(10,("altpath: .%s. refcnt: %d\n", altpath, jn.referral_count));
for(i=0;i<jn.referral_count;i++)
{
pstring refpath;
pstrcpy(refpath,jn.referral_list[i].alternate_path);
trim_string(refpath, "\\", "\\");
+ DEBUG(10,("_dfs_remove: refpath: .%s.\n", refpath));
if(strequal(refpath, altpath))
{
*(jn.referral_list[i].alternate_path)='\0';
+ DEBUG(10,("_dfs_remove: Removal request matches referral %s\n",
+ refpath));
found = True;
}
}
@@ -185,7 +191,7 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u
}
}
- return NT_STATUS_NOPROBLEMO;
+ return ERRsuccess;
}
static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j)
@@ -227,8 +233,13 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I
{
pstring str;
dfs3[i].ptr_entrypath = 1;
- slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname,
- j[i].service_name, j[i].volume_name);
+ if (j[i].volume_name[0] == '\0')
+ slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s",
+ global_myname, j[i].service_name);
+ else
+ slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname,
+ j[i].service_name, j[i].volume_name);
+
init_unistr2(&dfs3[i].entrypath, str, strlen(str)+1);
dfs3[i].ptr_comment = 1;
init_unistr2(&dfs3[i].comment, "", 1);
@@ -309,7 +320,7 @@ static uint32 init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ct
default:
return NT_STATUS_INVALID_LEVEL;
}
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
uint32 _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u)
@@ -353,7 +364,7 @@ uint32 _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, DFS_R_DFS_GET_INF
if(!create_junction(path, &jn))
return NERR_DfsNoSuchServer;
- if(!get_referred_path(&jn))
+ if(!get_referred_path(path, &jn, NULL, NULL))
return NERR_DfsNoSuchVolume;
r_u->level = level;
diff --git a/source/rpc_server/srv_lsa_nt.c b/source/rpc_server/srv_lsa_nt.c
index afcace3f9c8..a14a479984b 100644
--- a/source/rpc_server/srv_lsa_nt.c
+++ b/source/rpc_server/srv_lsa_nt.c
@@ -176,7 +176,7 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l,
if (mapped_count == 0)
r_l->status = NT_STATUS_NONE_MAPPED;
else
- r_l->status = NT_STATUS_NO_PROBLEMO;
+ r_l->status = NT_STATUS_OK;
}
/***************************************************************************
@@ -276,7 +276,7 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
if (mapped_count == 0)
r_l->status = NT_STATUS_NONE_MAPPED;
else
- r_l->status = NT_STATUS_NO_PROBLEMO;
+ r_l->status = NT_STATUS_OK;
}
/***************************************************************************
@@ -291,7 +291,7 @@ uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2
if (!create_policy_hnd(p, &r_u->pol, NULL, NULL))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/***************************************************************************
@@ -306,7 +306,7 @@ uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_
if (!create_policy_hnd(p, &r_u->pol, NULL, NULL))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/***************************************************************************
@@ -323,8 +323,8 @@ uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENU
return NT_STATUS_INVALID_HANDLE;
/* set up the LSA QUERY INFO response */
- init_r_enum_trust_dom(r_u, enum_context, dom_name, dom_sid,
- dom_name != NULL ? NT_STATUS_NO_PROBLEMO : NT_STATUS_UNABLE_TO_FREE_VM);
+ init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, dom_name, dom_sid,
+ dom_name != NULL ? NT_STATUS_OK : NT_STATUS_UNABLE_TO_FREE_VM);
return r_u->status;
}
@@ -341,7 +341,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO
char *name = NULL;
DOM_SID *sid = NULL;
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
if (!find_policy_by_hnd(p, &q_u->pol, NULL))
return NT_STATUS_INVALID_HANDLE;
@@ -434,7 +434,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO
break;
}
- if(r_u->status == NT_STATUS_NO_PROBLEMO) {
+ if(r_u->status == NT_STATUS_OK) {
r_u->undoc_buffer = 0x22000000; /* bizarre */
r_u->info_class = q_u->info_class;
}
@@ -508,7 +508,7 @@ uint32 _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u)
return NT_STATUS_INVALID_HANDLE;
close_policy_hnd(p, &q_u->pol);
- return NT_STATUS_NO_PROBLEMO;
+ return NT_STATUS_OK;
}
/***************************************************************************
@@ -532,8 +532,8 @@ uint32 _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R
fstrcpy(username, vuser->user.smb_name);
fstrcpy(domname, vuser->user.domain);
- ulen = strlen(username);
- dlen = strlen(domname);
+ ulen = strlen(username) + 1;
+ dlen = strlen(domname) + 1;
init_uni_hdr(&r_u->hdr_user_name, ulen);
r_u->ptr_user_name = 1;
@@ -545,7 +545,7 @@ uint32 _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R
r_u->ptr_dom_name = 1;
init_unistr2(&r_u->uni2_dom_name, domname, dlen);
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
return r_u->status;
}
diff --git a/source/rpc_server/srv_netlog_nt.c b/source/rpc_server/srv_netlog_nt.c
index 5a7505869c5..62c49f5b89a 100644
--- a/source/rpc_server/srv_netlog_nt.c
+++ b/source/rpc_server/srv_netlog_nt.c
@@ -117,7 +117,9 @@ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s,
static BOOL get_md4pw(char *md4pw, char *mach_acct)
{
- struct smb_passwd *smb_pass;
+ SAM_ACCOUNT *sampass = NULL;
+ uint8 *pass;
+ BOOL ret;
#if 0
/*
@@ -136,22 +138,29 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct)
return False;
}
#endif /* 0 */
+ if(!pdb_init_sam(&sampass))
+ return False;
/* JRA. This is ok as it is only used for generating the challenge. */
-
become_root();
- smb_pass = getsmbpwnam(mach_acct);
+ ret=pdb_getsampwnam(sampass, mach_acct);
unbecome_root();
- if ((smb_pass) != NULL && !(smb_pass->acct_ctrl & ACB_DISABLED) &&
- (smb_pass->smb_nt_passwd != NULL))
- {
- memcpy(md4pw, smb_pass->smb_nt_passwd, 16);
- dump_data(5, md4pw, 16);
+ if (ret==False) {
+ DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct));
+ pdb_free_sam(sampass);
+ return False;
+ }
+ if (!(pdb_get_acct_ctrl(sampass) & ACB_DISABLED) && ((pass=pdb_get_nt_passwd(sampass)) != NULL)) {
+ memcpy(md4pw, pass, 16);
+ dump_data(5, md4pw, 16);
+ pdb_free_sam(sampass);
return True;
}
+
DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct));
+ pdb_free_sam(sampass);
return False;
}
@@ -161,7 +170,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct)
uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
fstring mach_acct;
if (!get_valid_user_struct(p->vuid))
@@ -220,7 +229,7 @@ static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, int status)
uint32 _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
DOM_CHAL srv_cred;
UTIME srv_time;
@@ -266,7 +275,7 @@ static void init_net_r_auth_2(NET_R_AUTH_2 *r_a,
uint32 _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
DOM_CHAL srv_cred;
UTIME srv_time;
NEG_FLAGS srv_flgs;
@@ -303,11 +312,11 @@ uint32 _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u)
uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
DOM_CRED srv_cred;
pstring mach_acct;
- struct smb_passwd *smb_pass;
- BOOL ret;
+ SAM_ACCOUNT *sampass=NULL;
+ BOOL ret=False;
unsigned char pwd[16];
int i;
@@ -325,24 +334,33 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_
pstrcpy(mach_acct, dos_unistrn2(q_u->clnt_id.login.uni_acct_name.buffer,
q_u->clnt_id.login.uni_acct_name.uni_str_len));
+ DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct));
+
+ pdb_init_sam(&sampass);
+
+ become_root();
+ ret=pdb_getsampwnam(sampass, mach_acct);
+ unbecome_root();
+
+ /* Ensure the account exists and is a machine account. */
+
+ if (ret==False || !(pdb_get_acct_ctrl(sampass) & ACB_WSTRUST)) {
+ pdb_free_sam(sampass);
+ return NT_STATUS_NO_SUCH_USER;
+ }
+
+
/*
* Check the machine account name we're changing is the same
* as the one we've authenticated from. This prevents arbitrary
* machines changing other machine account passwords.
*/
- if (!strequal(mach_acct, p->dc.mach_acct))
+ if (!strequal(mach_acct, p->dc.mach_acct)) {
+ pdb_free_sam(sampass);
return NT_STATUS_ACCESS_DENIED;
+ }
- DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct));
-
- become_root();
- smb_pass = getsmbpwnam(mach_acct);
- unbecome_root();
-
- /* Ensure the account exists and is a machine account. */
- if (smb_pass == NULL || !(smb_pass->acct_ctrl & ACB_WSTRUST))
- return NT_STATUS_NO_SUCH_USER;
DEBUG(100,("Server password set : new given value was :\n"));
for(i = 0; i < 16; i++)
@@ -352,20 +370,27 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_
cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0);
/* lies! nt and lm passwords are _not_ the same: don't care */
- smb_pass->smb_passwd = pwd;
- smb_pass->smb_nt_passwd = pwd;
- smb_pass->acct_ctrl = ACB_WSTRUST;
-
+ if (!pdb_set_lanman_passwd (sampass, pwd)) {
+ pdb_free_sam(sampass);
+ return NT_STATUS_NO_MEMORY;
+ }
+ if (!pdb_set_nt_passwd(sampass, pwd)) {
+ pdb_free_sam(sampass);
+ return NT_STATUS_NO_MEMORY;
+ }
+ pdb_set_acct_ctrl (sampass, ACB_WSTRUST);
+
become_root();
- ret = mod_smbpwd_entry(smb_pass,False);
+ ret = pdb_update_sam_account (sampass,False);
unbecome_root();
- if (!ret)
- status = NT_STATUS_WRONG_PASSWORD;
+ if (ret)
+ status = NT_STATUS_OK;
/* set up the LSA Server Password Set response */
init_net_r_srv_pwset(r_u, &srv_cred, status);
+ pdb_free_sam(sampass);
return r_u->status;
}
@@ -392,7 +417,7 @@ uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF
r_u->buffer_creds = 1; /* yes, we have valid server credentials */
memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds));
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
return r_u->status;
}
@@ -401,10 +426,9 @@ uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF
net_login_interactive:
*************************************************************************/
-static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_pass, pipes_struct *p)
+static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, pipes_struct *p)
{
- uint32 status = 0x0;
-
+ uint8 *stored_nt_pwd, *stored_lanman_pwd;
char nt_pwd[16];
char lm_pwd[16];
unsigned char key[16];
@@ -437,21 +461,42 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_p
dump_data(100, nt_pwd, 16);
#endif
- if (memcmp(smb_pass->smb_passwd , lm_pwd, 16) != 0 ||
- memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0)
- {
- status = NT_STATUS_WRONG_PASSWORD;
+ /* JRA. Check the NT password first if it exists - this is a higher quality
+ password, if it exists and it doesn't match - fail. */
+
+ stored_nt_pwd = pdb_get_nt_passwd(sampass);
+
+ if (stored_nt_pwd) {
+ if (memcmp(stored_nt_pwd, nt_pwd, 16) != 0) {
+ DEBUG(10,("net_login_interactive: NT password for user %s doesn't match.\n",
+ sampass->username));
+ return NT_STATUS_WRONG_PASSWORD;
+ } else
+ return NT_STATUS_OK;
}
- return status;
+ stored_lanman_pwd = pdb_get_lanman_passwd(sampass);
+
+ if (stored_lanman_pwd && lp_lanman_auth()) {
+ if (memcmp(stored_lanman_pwd, lm_pwd, 16) != 0) {
+ DEBUG(10,("net_login_interactive: lanman password for user %s doesn't match.\n",
+ sampass->username));
+ return NT_STATUS_WRONG_PASSWORD;
+ } else
+ return NT_STATUS_OK;
+ }
+
+ return NT_STATUS_WRONG_PASSWORD;
}
/*************************************************************************
_net_login_network:
*************************************************************************/
-static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass)
+static uint32 net_login_network(NET_ID_INFO_2 *id2, SAM_ACCOUNT *sampass)
{
+ uint8 *nt_pwd, *lanman_pwd;
+
DEBUG(5,("net_login_network: lm_len: %d nt_len: %d\n",
id2->hdr_lm_chal_resp.str_str_len,
id2->hdr_nt_chal_resp.str_str_len));
@@ -459,13 +504,12 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass)
/* JRA. Check the NT password first if it exists - this is a higher quality
password, if it exists and it doesn't match - fail. */
- if (id2->hdr_nt_chal_resp.str_str_len == 24 &&
- smb_pass->smb_nt_passwd != NULL)
- {
- if(smb_password_check((char *)id2->nt_chal_resp.buffer,
- smb_pass->smb_nt_passwd,
- id2->lm_chal))
- return NT_STATUS_NO_PROBLEMO;
+ nt_pwd = pdb_get_nt_passwd(sampass);
+ lanman_pwd = pdb_get_lanman_passwd(sampass);
+
+ if (id2->hdr_nt_chal_resp.str_str_len == 24 && nt_pwd != NULL) {
+ if(smb_password_check((char *)id2->nt_chal_resp.buffer, nt_pwd, id2->lm_chal))
+ return NT_STATUS_OK;
else
return NT_STATUS_WRONG_PASSWORD;
}
@@ -478,13 +522,11 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass)
not do, for various security-hole reasons).
*/
- if (lp_lanman_auth() &&
- id2->hdr_lm_chal_resp.str_str_len == 24 &&
+ if (lp_lanman_auth() && id2->hdr_lm_chal_resp.str_str_len == 24 &&
smb_password_check((char *)id2->lm_chal_resp.buffer,
- smb_pass->smb_passwd,
- id2->lm_chal))
+ lanman_pwd, id2->lm_chal))
{
- return NT_STATUS_NO_PROBLEMO;
+ return NT_STATUS_OK;
}
@@ -499,13 +541,14 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass)
uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
NET_USER_INFO_3 *usr_info = NULL;
DOM_CRED srv_cred;
- struct smb_passwd *smb_pass = NULL;
- struct sam_passwd *sam_pass = NULL;
+ SAM_ACCOUNT *sampass = NULL;
UNISTR2 *uni_samlogon_user = NULL;
fstring nt_username;
+ BOOL ret;
+ uint16 acct_ctrl;
usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3));
if (!usr_info)
@@ -560,92 +603,62 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_
map_username(nt_username);
- /*
- * We previously called Get_Pwnam(ntusername, True) here which could
- * have modified the case of the username. Beaware of this
- * is the username case in smbpasswd does not match that in /etc/passwd
- * and domain logons begin to fail. -- jerry
- */
-
- /* XXXX hack to get standard_sub_basic() to use sam logon username */
- /* possibly a better way would be to do a become_user() call */
- sam_logon_in_ssb = True;
- pstrcpy(samlogon_user, nt_username);
-
+ /* get the account information */
+ pdb_init_sam(&sampass);
become_root();
- sam_pass = getsam21pwnam(nt_username);
+ ret = pdb_getsampwnam(sampass, nt_username);
unbecome_root();
- smb_pass = pdb_sam_to_smb(sam_pass);
- sam_logon_in_ssb = False;
-
- if ((smb_pass=pdb_sam_to_smb(sam_pass)) == NULL)
+ if (!ret)
return NT_STATUS_NO_SUCH_USER;
- else if (smb_pass->acct_ctrl & ACB_DISABLED)
- return NT_STATUS_ACCOUNT_DISABLED;
-
- /* Validate password - if required. */
-
- if (smb_pass->acct_ctrl & ACB_PWNOTREQ) {
- if (!lp_null_passwords()) {
- DEBUG(3,("Account for user %s has a null password and null passwords are NOT allowed",nt_username));
- return NT_STATUS_ACCOUNT_DISABLED;
- }
- }
-#ifdef WITH_PAM
- become_root();
-#if 0 /* JERRY */
- status = smb_pam_accountcheck(nt_username);
-#else
- status = smb_pam_accountcheck(sam_pass->smb_name);
-#endif
- unbecome_root();
- if (status != NT_STATUS_NOPROBLEMO)
- return status;
-#endif
+ acct_ctrl = pdb_get_acct_ctrl(sampass);
- if (!(smb_pass->acct_ctrl & ACB_PWNOTREQ)) {
+ /* Validate password - if required. */
+
+ if (!(acct_ctrl & ACB_PWNOTREQ)) {
switch (q_u->sam_id.logon_level) {
case INTERACTIVE_LOGON_TYPE:
/* interactive login. */
- status = net_login_interactive(&q_u->sam_id.ctr->auth.id1, smb_pass, p);
+ status = net_login_interactive(&q_u->sam_id.ctr->auth.id1, sampass, p);
break;
case NET_LOGON_TYPE:
/* network login. lm challenge and 24 byte responses */
- status = net_login_network(&q_u->sam_id.ctr->auth.id2, smb_pass);
+ status = net_login_network(&q_u->sam_id.ctr->auth.id2, sampass);
break;
}
}
-
- if (status != NT_STATUS_NOPROBLEMO)
+
+ if (status != NT_STATUS_OK)
return status;
+#ifdef WITH_PAM
+ become_root();
+ status = smb_pam_accountcheck(pdb_get_username(sampass));
+ unbecome_root();
+ if (status != NT_STATUS_OK)
+ return status;
+#endif
+
+ if (acct_ctrl & ACB_DISABLED)
+ return NT_STATUS_ACCOUNT_DISABLED;
+
/* lkclXXXX this is the point at which, if the login was
successful, that the SAM Local Security Authority should
record that the user is logged in to the domain.
*/
- /* return the profile plus other bits :-) */
-
{
DOM_GID *gids = NULL;
int num_gids = 0;
- NTTIME dummy_time;
pstring my_name;
pstring my_workgroup;
pstring domain_groups;
- uint32 r_uid;
- uint32 r_gid;
/* set up pointer indicating user/password failed to be found */
usr_info->ptr_user_info = 0;
- dummy_time.low = 0xffffffff;
- dummy_time.high = 0x7fffffff;
-
pstrcpy(my_workgroup, lp_workgroup());
-
pstrcpy(my_name, global_myname);
strupper(my_name);
@@ -665,44 +678,17 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_
gids = NULL;
num_gids = make_dom_gids(p->mem_ctx, domain_groups, &gids);
- if (pdb_name_to_rid(nt_username, &r_uid, &r_gid))
- {
- init_net_user_info3(p->mem_ctx, usr_info,
- &dummy_time, /* logon_time */
- &dummy_time, /* logoff_time */
- &dummy_time, /* kickoff_time */
- &dummy_time, /* pass_last_set_time */
- &dummy_time, /* pass_can_change_time */
- &dummy_time, /* pass_must_change_time */
-
- nt_username , /* user_name */
- sam_pass->full_name, /* full_name */
- sam_pass->logon_script , /* logon_script */
- sam_pass->profile_path , /* profile_path */
- sam_pass->home_dir , /* home_dir */
- sam_pass->dir_drive , /* dir_drive */
-
- 0, /* logon_count */
- 0, /* bad_pw_count */
-
- r_uid , /* RID user_id */
- r_gid , /* RID group_id */
- num_gids, /* uint32 num_groups */
- gids , /* DOM_GID *gids */
- 0x20 , /* uint32 user_flgs (?) */
-
- NULL, /* char sess_key[16] */
-
- my_name , /* char *logon_srv */
- my_workgroup, /* char *logon_dom */
-
- &global_sam_sid, /* DOM_SID *dom_sid */
- NULL); /* char *other_sids */
- }
- else
- {
- return NT_STATUS_NO_SUCH_USER;
- }
+ init_net_user_info3(p->mem_ctx, usr_info, sampass,
+ 0, /* logon_count */
+ 0, /* bad_pw_count */
+ num_gids, /* uint32 num_groups */
+ gids , /* DOM_GID *gids */
+ 0x20 , /* uint32 user_flgs (?) */
+ NULL, /* char sess_key[16] */
+ my_name , /* char *logon_srv */
+ my_workgroup, /* char *logon_dom */
+ &global_sam_sid, /* DOM_SID *dom_sid */
+ NULL); /* char *other_sids */
}
diff --git a/source/rpc_server/srv_pipe.c b/source/rpc_server/srv_pipe.c
index d16290985ec..174a21a4c50 100644
--- a/source/rpc_server/srv_pipe.c
+++ b/source/rpc_server/srv_pipe.c
@@ -269,8 +269,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm
fstring domain;
fstring wks;
BOOL guest_user = False;
- struct smb_passwd *smb_pass = NULL;
- struct passwd *pass = NULL;
+ SAM_ACCOUNT *sampass = NULL;
uchar null_smb_passwd[16];
uchar *smb_passwd_ptr = NULL;
@@ -359,15 +358,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm
}
- /*
- * Find the user in the unix password db.
- */
-
- if(!(pass = Get_Pwnam(pipe_user_name,True))) {
- DEBUG(1,("Couldn't find user '%s' in UNIX password database.\n",pipe_user_name));
- return(False);
- }
-
if(!guest_user) {
become_root();
@@ -380,33 +370,32 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name
return False;
}
- if(!(smb_pass = getsmbpwnam(pipe_user_name))) {
+ pdb_init_sam(&sampass);
+
+ if(!pdb_getsampwnam(sampass, pipe_user_name)) {
DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n",
pipe_user_name));
+ pdb_free_sam(sampass);
unbecome_root();
return False;
}
-
+
unbecome_root();
- if (smb_pass == NULL) {
- DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n",
- pipe_user_name));
- return(False);
- }
-
- /* Quit if the account was disabled. */
- if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) {
+ /* Quit if the account was disabled. */
+ if((pdb_get_acct_ctrl(sampass) & ACB_DISABLED) || !pdb_get_lanman_passwd(sampass)) {
DEBUG(1,("Account for user '%s' was disabled.\n", pipe_user_name));
- return(False);
- }
-
- if(!smb_pass->smb_nt_passwd) {
+ pdb_free_sam(sampass);
+ return False;
+ }
+
+ if(!pdb_get_nt_passwd(sampass)) {
DEBUG(1,("Account for user '%s' has no NT password hash.\n", pipe_user_name));
- return(False);
- }
-
- smb_passwd_ptr = smb_pass->smb_passwd;
+ pdb_free_sam(sampass);
+ return False;
+ }
+
+ smb_passwd_ptr = pdb_get_lanman_passwd(sampass);
}
/*
@@ -457,8 +446,8 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name
* Store the UNIX credential data (uid/gid pair) in the pipe structure.
*/
- p->pipe_user.uid = pass->pw_uid;
- p->pipe_user.gid = pass->pw_gid;
+ p->pipe_user.uid = pdb_get_uid(sampass);
+ p->pipe_user.gid = pdb_get_gid(sampass);
/* Set up pipe user group membership. */
initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid);
diff --git a/source/rpc_server/srv_pipe_hnd.c b/source/rpc_server/srv_pipe_hnd.c
index f91df7c4ef4..c9fb06da4db 100644
--- a/source/rpc_server/srv_pipe_hnd.c
+++ b/source/rpc_server/srv_pipe_hnd.c
@@ -775,10 +775,15 @@ ssize_t read_from_pipe(pipes_struct *p, char *data, size_t n)
* read request.
*/
+ /*
+ * This condition should result in the connection being closed.
+ * Netapp filers seem to set it to 0xffff which results in domain
+ * authentications failing. Just ignore it so things work.
+ */
+
if(n > MAX_PDU_FRAG_LEN) {
- DEBUG(0,("read_from_pipe: loo large read (%u) requested on pipe %s. We can \
-only service %d sized reads.\n", (unsigned int)n, p->name, MAX_PDU_FRAG_LEN ));
- return -1;
+ DEBUG(5,("read_from_pipe: too large read (%u) requested on \
+pipe %s. We can only service %d sized reads.\n", (unsigned int)n, p->name, MAX_PDU_FRAG_LEN ));
}
/*
diff --git a/source/rpc_server/srv_reg_nt.c b/source/rpc_server/srv_reg_nt.c
index 502d5514378..c3b4a1a7a5d 100644
--- a/source/rpc_server/srv_reg_nt.c
+++ b/source/rpc_server/srv_reg_nt.c
@@ -55,7 +55,7 @@ uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u)
if (!close_policy_hnd(p, &q_u->pol))
return NT_STATUS_OBJECT_NAME_INVALID;
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -67,7 +67,7 @@ uint32 _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u)
if (!create_policy_hnd(p, &r_u->pol, free_reg_info, NULL))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -103,7 +103,7 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY
if (!create_policy_hnd(p, &pol, free_reg_info, (void *)info))
return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */
- init_reg_r_open_entry(r_u, &pol, NT_STATUS_NOPROBLEMO);
+ init_reg_r_open_entry(r_u, &pol, NT_STATUS_OK);
DEBUG(5,("reg_open_entry: %d\n", __LINE__));
@@ -116,7 +116,7 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY
uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
char *key = NULL;
uint32 type=0x1; /* key type: REG_SZ */
diff --git a/source/rpc_server/srv_samr_nt.c b/source/rpc_server/srv_samr_nt.c
index e0d80a3f9a1..9c2f37d4ce0 100644
--- a/source/rpc_server/srv_samr_nt.c
+++ b/source/rpc_server/srv_samr_nt.c
@@ -65,134 +65,156 @@ static uint32 get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx,
int *total_entries, int *num_entries,
int max_num_entries, uint16 acb_mask)
{
- void *vp = NULL;
- struct sam_passwd *pwd = NULL;
+ SAM_ACCOUNT *pwd = NULL;
+ BOOL not_finished = True;
- (*num_entries) = 0;
- (*total_entries) = 0;
+ (*num_entries) = 0;
+ (*total_entries) = 0;
- if (pw_buf == NULL)
- return NT_STATUS_NO_MEMORY;
+ if (pw_buf == NULL)
+ return NT_STATUS_NO_MEMORY;
- vp = startsmbpwent(False);
- if (!vp) {
- DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n"));
- return NT_STATUS_ACCESS_DENIED;
- }
+ pdb_init_sam(&pwd);
- while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) {
- int user_name_len;
+ if (!pdb_setsampwent(False)) {
+ DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n"));
+ pdb_free_sam(pwd);
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ while (((not_finished = pdb_getsampwent(pwd)) != False)
+ && (*num_entries) < max_num_entries)
+ {
+ int user_name_len;
- if (start_idx > 0) {
- /* skip the requested number of entries.
- not very efficient, but hey...
- */
- start_idx--;
- continue;
+ if (start_idx > 0) {
+ /* skip the requested number of entries.
+ not very efficient, but hey... */
+ pdb_reset_sam(pwd);
+ start_idx--;
+ continue;
}
- user_name_len = strlen(pwd->smb_name)+1;
- init_unistr2(&pw_buf[(*num_entries)].uni_user_name, pwd->smb_name, user_name_len);
- init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len);
- pw_buf[(*num_entries)].user_rid = pwd->user_rid;
- memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16);
+ user_name_len = strlen(pdb_get_username(pwd))+1;
+ init_unistr2(&pw_buf[(*num_entries)].uni_user_name, pdb_get_username(pwd), user_name_len);
+ init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len);
+ pw_buf[(*num_entries)].user_rid = pwd->user_rid;
+ memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16);
- /* Now check if the NT compatible password is available. */
- if (pwd->smb_nt_passwd != NULL) {
- memcpy( pw_buf[(*num_entries)].nt_pwd , pwd->smb_nt_passwd, 16);
- }
+ /* Now check if the NT compatible password is available. */
+ if (pdb_get_nt_passwd(pwd))
+ memcpy( pw_buf[(*num_entries)].nt_pwd , pdb_get_nt_passwd(pwd), 16);
- pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl;
+ pw_buf[(*num_entries)].acb_info = pdb_get_acct_ctrl(pwd);
- DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x",
- (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl));
+ DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x",
+ (*num_entries), pdb_get_username(pwd), pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd) ));
- if (acb_mask == 0 || (pwd->acct_ctrl & acb_mask)) {
- DEBUG(5,(" acb_mask %x accepts\n", acb_mask));
- (*num_entries)++;
- }
- else
- DEBUG(5,(" acb_mask %x rejects\n", acb_mask));
+ if (acb_mask == 0 || (pwd->acct_ctrl & acb_mask)) {
+ DEBUG(5,(" acb_mask %x accepts\n", acb_mask));
+ (*num_entries)++;
+ } else
+ DEBUG(5,(" acb_mask %x rejects\n", acb_mask));
- (*total_entries)++;
- }
+ (*total_entries)++;
+ pdb_reset_sam(pwd);
+ }
- endsmbpwent(vp);
+ pdb_endsampwent();
+ pdb_free_sam(pwd);
- if (pwd!=NULL)
+ if (not_finished)
return STATUS_MORE_ENTRIES;
else
- return NT_STATUS_NO_PROBLEMO;
+ return NT_STATUS_OK;
}
static uint32 jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx,
int *total_entries, uint32 *num_entries,
int max_num_entries, uint16 acb_mask)
{
- void *vp = NULL;
- struct sam_passwd *pwd = NULL;
+ SAM_ACCOUNT *pwd = NULL;
+ BOOL not_finished = True;
*num_entries = 0;
*total_entries = 0;
if (pw_buf == NULL)
return NT_STATUS_NO_MEMORY;
+
+ DEBUG(10,("jf_get_sampwd_entries: start index:%d, max entries:%d, mask:%d\n",
+ start_idx, max_num_entries, acb_mask));
- vp = startsmbpwent(False);
- if (!vp) {
- DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n"));
+ if (!pdb_setsampwent(False)) {
+ DEBUG(0, ("jf_get_sampwd_entries: Unable to open passdb.\n"));
return NT_STATUS_ACCESS_DENIED;
}
- while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) {
+ pdb_init_sam(&pwd);
+
+ while (((not_finished = pdb_getsampwent(pwd)) != False) && (*num_entries) < max_num_entries) {
int user_name_len;
int full_name_len;
- if (acb_mask != 0 && !(pwd->acct_ctrl & acb_mask))
+ if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) {
+ pdb_reset_sam(pwd);
continue;
+ }
if (start_idx > 0) {
/* skip the requested number of entries.
not very efficient, but hey...
*/
start_idx--;
+ pdb_reset_sam(pwd);
continue;
}
ZERO_STRUCTP(&pw_buf[(*num_entries)]);
- user_name_len = strlen(pwd->smb_name);
- init_unistr2(&pw_buf[(*num_entries)].uni_user_name, pwd->smb_name, user_name_len);
+ user_name_len = strlen(pdb_get_username(pwd));
+ init_unistr2(&pw_buf[(*num_entries)].uni_user_name, pdb_get_username(pwd), user_name_len);
init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len);
- full_name_len = strlen(pwd->full_name);
- init_unistr2(&pw_buf[(*num_entries)].uni_full_name, pwd->full_name, full_name_len);
+ full_name_len = strlen(pdb_get_fullname(pwd));
+ init_unistr2(&pw_buf[(*num_entries)].uni_full_name, pdb_get_fullname(pwd), full_name_len);
init_uni_hdr(&pw_buf[(*num_entries)].hdr_full_name, full_name_len);
- pw_buf[(*num_entries)].user_rid = pwd->user_rid;
+ pw_buf[(*num_entries)].user_rid = pdb_get_user_rid(pwd);
memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16);
/* Now check if the NT compatible password is available. */
- if (pwd->smb_nt_passwd != NULL) {
- memcpy( pw_buf[(*num_entries)].nt_pwd , pwd->smb_nt_passwd, 16);
- }
+ if (pdb_get_nt_passwd(pwd))
+ memcpy( pw_buf[(*num_entries)].nt_pwd , pdb_get_nt_passwd(pwd), 16);
+
+ pw_buf[(*num_entries)].acb_info = pdb_get_acct_ctrl(pwd);
- pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl;
+ DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x\n", (*num_entries),
+ pdb_get_username(pwd), pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd) ));
- DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x\n", (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl));
(*num_entries)++;
+
+ pdb_reset_sam(pwd);
}
- endsmbpwent(vp);
+ pdb_endsampwent();
*total_entries = *num_entries;
+
+ pdb_free_sam(pwd);
- if (pwd!=NULL)
+ if (not_finished)
return STATUS_MORE_ENTRIES;
else
- return NT_STATUS_NO_PROBLEMO;
+ return NT_STATUS_OK;
}
+/*
+ * These next two functions are not used. Tagged
+ * for deletion
+ */
+
+#if 0
/*******************************************************************
This function uses the username map file and tries to map a UNIX
user name to an DOS name. (Sort of the reverse of the
@@ -439,6 +461,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf,
done:
return (*num_entries) > 0;
}
+#endif
/*******************************************************************
_samr_close_hnd
@@ -446,7 +469,7 @@ done:
uint32 _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND *r_u)
{
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* close the policy handle */
if (!close_policy_hnd(p, &q_u->pol))
@@ -465,7 +488,7 @@ uint32 _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_D
{
struct samr_info *info;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* find the connection policy handle. */
if (!find_policy_by_hnd(p, &q_u->pol, NULL))
@@ -505,7 +528,7 @@ uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, S
{
struct samr_info *info = NULL;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* find the policy handle. open a policy on it. */
if (!find_policy_by_hnd(p, &q_u->user_pol, (void **)&info)) {
@@ -517,7 +540,7 @@ uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, S
return NT_STATUS_OBJECT_TYPE_MISMATCH;
}
- init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_NOPROBLEMO);
+ init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_OK);
DEBUG(5,("_samr_get_usrdom_pwinfo: %d\n", __LINE__));
@@ -567,7 +590,7 @@ static uint32 samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID
if((*buf = make_sec_desc_buf(ctx, sd_size, psd)) == NULL)
return NT_STATUS_NO_MEMORY;
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *sid)
@@ -593,7 +616,7 @@ uint32 _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QU
{
DOM_SID pol_sid;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* Get the SID. */
@@ -602,7 +625,7 @@ uint32 _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QU
r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &r_u->buf, &pol_sid);
- if (r_u->status == NT_STATUS_NOPROBLEMO)
+ if (r_u->status == NT_STATUS_OK)
r_u->ptr = 1;
return r_u->status;
@@ -625,9 +648,9 @@ static void make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR
if (num_sam_entries == 0)
return;
- sam = (SAM_ENTRY *)talloc(ctx, sizeof(SAM_ENTRY)*num_sam_entries);
+ sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_sam_entries);
- uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2)*num_sam_entries);
+ uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_sam_entries);
if (sam == NULL || uni_name == NULL) {
DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n"));
@@ -662,15 +685,13 @@ static void samr_clear_passwd_fields( SAM_USER_INFO_21 *pass, int num_entries)
}
}
-static void samr_clear_sam_passwd( struct sam_passwd *sam_pass)
+static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass)
{
if (!sam_pass)
return;
- if (sam_pass->smb_passwd)
- memset(sam_pass->smb_passwd, '\0', 16);
- if (sam_pass->smb_nt_passwd)
- memset(sam_pass->smb_nt_passwd, '\0', 16);
+ if (sam_pass->lm_pw) memset(sam_pass->lm_pw, '\0', 16);
+ if (sam_pass->nt_pw) memset(sam_pass->nt_pw, '\0', 16);
}
/*******************************************************************
@@ -683,7 +704,7 @@ uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_
int num_entries = 0;
int total_entries = 0;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* find the policy handle. open a policy on it. */
if (!find_policy_by_hnd(p, &q_u->pol, NULL))
@@ -696,7 +717,7 @@ uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_
MAX_SAM_ENTRIES, q_u->acb_mask);
unbecome_root();
- if (r_u->status != NT_STATUS_NOPROBLEMO && r_u->status != STATUS_MORE_ENTRIES)
+ if (r_u->status != NT_STATUS_OK && r_u->status != STATUS_MORE_ENTRIES)
return r_u->status;
samr_clear_passwd_fields(pass, num_entries);
@@ -740,9 +761,9 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNIST
if (num_sam_entries == 0)
return;
- sam = (SAM_ENTRY *)talloc(ctx, sizeof(SAM_ENTRY)*num_sam_entries);
+ sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_sam_entries);
- uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2)*num_sam_entries);
+ uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_sam_entries);
if (sam == NULL || uni_name == NULL) {
DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n"));
@@ -767,7 +788,7 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNIST
Get the group entries - similar to get_sampwd_entries().
********************************************************************/
-static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 start_idx,
+static uint32 get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 start_idx,
uint32 *p_num_entries, uint32 max_entries)
{
fstring sid_str;
@@ -809,7 +830,7 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star
* libc grent structures overwrites by called functions */
grp = glist = getgrent_list();
if (grp == NULL)
- return False;
+ return NT_STATUS_NO_MEMORY;
for (;(num_entries < max_entries) && (grp != NULL); grp = grp->next) {
int i;
@@ -859,7 +880,9 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star
*p_num_entries = num_entries;
- return True;
+ if (num_entries >= max_entries)
+ return STATUS_MORE_ENTRIES;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -894,7 +917,7 @@ static uint32 get_group_domain_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 s
*p_num_entries = num_entries;
- return NT_STATUS_NO_PROBLEMO;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -909,7 +932,7 @@ uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_
uint32 num_entries;
DOM_SID sid;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid))
return NT_STATUS_INVALID_HANDLE;
@@ -939,7 +962,7 @@ uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAM
fstring sid_str;
DOM_SID sid;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid))
return NT_STATUS_INVALID_HANDLE;
@@ -947,12 +970,15 @@ uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAM
sid_to_string(sid_str, &sid);
DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str));
- if (!get_group_alias_entries(grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES))
- return NT_STATUS_ACCESS_DENIED;
+ r_u->status = get_group_alias_entries(grp, &sid, q_u->start_idx,
+ &num_entries, MAX_SAM_ENTRIES);
+
+ if (r_u->status != NT_STATUS_OK && r_u->status != STATUS_MORE_ENTRIES)
+ return r_u->status;
make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp);
- init_samr_r_enum_dom_aliases(r_u, q_u->start_idx, num_entries);
+ init_samr_r_enum_dom_aliases(r_u, q_u->start_idx + num_entries, num_entries);
DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__));
@@ -978,7 +1004,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_
DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__));
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid))
return NT_STATUS_INVALID_HANDLE;
@@ -1013,7 +1039,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_
MAX_SAM_ENTRIES, acb_mask);
#endif
unbecome_root();
- if (r_u->status!=STATUS_MORE_ENTRIES && r_u->status!=NT_STATUS_NO_PROBLEMO) {
+ if (r_u->status!=STATUS_MORE_ENTRIES && r_u->status!=NT_STATUS_OK) {
DEBUG(5, ("get_sampwd_entries: failed\n"));
return r_u->status;
}
@@ -1021,7 +1047,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_
case 0x3:
case 0x5:
r_u->status = get_group_domain_entries(grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES);
- if (r_u->status!=NT_STATUS_NO_PROBLEMO)
+ if (r_u->status!=NT_STATUS_OK)
return NT_STATUS_ACCESS_DENIED;
break;
default:
@@ -1044,45 +1070,57 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_
data_size = q_u->max_size;
- ctr = (SAM_DISPINFO_CTR *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_CTR));
+ ctr = (SAM_DISPINFO_CTR *)talloc_zero(p->mem_ctx,sizeof(SAM_DISPINFO_CTR));
if (!ctr)
return NT_STATUS_NO_MEMORY;
+ ZERO_STRUCTP(ctr);
+
/* Now create reply structure */
switch (q_u->switch_level) {
case 0x1:
- if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_1))))
- return NT_STATUS_NO_MEMORY;
+ if (num_entries) {
+ if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_1))))
+ return NT_STATUS_NO_MEMORY;
+ }
disp_ret = init_sam_dispinfo_1(p->mem_ctx,ctr->sam.info1, &num_entries, &data_size, q_u->start_idx, pass);
- if (disp_ret != NT_STATUS_NO_PROBLEMO)
+ if (disp_ret != NT_STATUS_OK)
return disp_ret;
break;
case 0x2:
- if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_2))))
- return NT_STATUS_NO_MEMORY;
+ if (num_entries) {
+ if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_2))))
+ return NT_STATUS_NO_MEMORY;
+ }
disp_ret = init_sam_dispinfo_2(p->mem_ctx,ctr->sam.info2, &num_entries, &data_size, q_u->start_idx, pass);
- if (disp_ret != NT_STATUS_NO_PROBLEMO)
+ if (disp_ret != NT_STATUS_OK)
return disp_ret;
break;
case 0x3:
- if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_3))))
- return NT_STATUS_NO_MEMORY;
+ if (num_entries) {
+ if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_3))))
+ return NT_STATUS_NO_MEMORY;
+ }
disp_ret = init_sam_dispinfo_3(p->mem_ctx,ctr->sam.info3, &num_entries, &data_size, q_u->start_idx, grps);
- if (disp_ret != NT_STATUS_NO_PROBLEMO)
+ if (disp_ret != NT_STATUS_OK)
return disp_ret;
break;
case 0x4:
- if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_4))))
- return NT_STATUS_NO_MEMORY;
+ if (num_entries) {
+ if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_4))))
+ return NT_STATUS_NO_MEMORY;
+ }
disp_ret = init_sam_dispinfo_4(p->mem_ctx,ctr->sam.info4, &num_entries, &data_size, q_u->start_idx, pass);
- if (disp_ret != NT_STATUS_NO_PROBLEMO)
+ if (disp_ret != NT_STATUS_OK)
return disp_ret;
break;
case 0x5:
- if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_5))))
- return NT_STATUS_NO_MEMORY;
+ if (num_entries) {
+ if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_5))))
+ return NT_STATUS_NO_MEMORY;
+ }
disp_ret = init_sam_dispinfo_5(p->mem_ctx,ctr->sam.info5, &num_entries, &data_size, q_u->start_idx, grps);
- if (disp_ret != NT_STATUS_NO_PROBLEMO)
+ if (disp_ret != NT_STATUS_OK)
return disp_ret;
break;
default:
@@ -1112,7 +1150,7 @@ uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_
uint32 alias_rid;
struct samr_info *info = NULL;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__));
@@ -1152,7 +1190,7 @@ uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_
uint32 rid[MAX_SAM_ENTRIES];
int num_rids = q_u->num_sids1;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__));
@@ -1194,7 +1232,7 @@ uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_
num_rids = 1;
rid[0] = BUILTIN_ALIAS_RID_USERS;
- init_samr_r_lookup_ids(&r_u, num_rids, rid, NT_STATUS_NOPROBLEMO);
+ init_samr_r_lookup_ids(&r_u, num_rids, rid, NT_STATUS_OK);
DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__));
@@ -1214,7 +1252,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK
int num_rids = q_u->num_names2;
DOM_SID pol_sid;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
DEBUG(5,("_samr_lookup_names: %d\n", __LINE__));
@@ -1245,7 +1283,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK
DOM_SID sid;
if(local_lookup_name(global_myname, name, &sid, &type[i])) {
sid_split_rid( &sid, &rid[i]);
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
}
}
}
@@ -1268,7 +1306,7 @@ uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_
DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__));
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
fstrcpy(user_name, dos_unistrn2(q_u->uni_user_name.buffer, q_u->uni_user_name.uni_str_len));
fstrcpy(wks , dos_unistrn2(q_u->uni_dest_host.buffer, q_u->uni_dest_host.uni_str_len));
@@ -1313,11 +1351,11 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam
*pp_hdr_name = NULL;
if (num_names != 0) {
- hdr_name = (UNIHDR *)talloc(ctx, sizeof(UNIHDR)*num_names);
+ hdr_name = (UNIHDR *)talloc_zero(ctx, sizeof(UNIHDR)*num_names);
if (hdr_name == NULL)
return False;
- uni_name = (UNISTR2 *)talloc(ctx,sizeof(UNISTR2)*num_names);
+ uni_name = (UNISTR2 *)talloc_zero(ctx,sizeof(UNISTR2)*num_names);
if (uni_name == NULL)
return False;
}
@@ -1349,7 +1387,7 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP
int num_rids = q_u->num_rids1;
int i;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__));
@@ -1363,7 +1401,7 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP
}
if (num_rids) {
- if ((group_attrs = (uint32 *)talloc(p->mem_ctx, num_rids * sizeof(uint32))) == NULL)
+ if ((group_attrs = (uint32 *)talloc_zero(p->mem_ctx, num_rids * sizeof(uint32))) == NULL)
return NT_STATUS_NO_MEMORY;
}
@@ -1383,7 +1421,7 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP
sid_append_rid(&sid, q_u->rid[i]);
if (lookup_sid(&sid, domname, tmpname, &type)) {
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
group_attrs[i] = (uint32)type;
fstrcpy(group_names[i],tmpname);
}
@@ -1406,49 +1444,55 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP
uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u)
{
- struct sam_passwd *sam_pass;
- DOM_SID sid;
- POLICY_HND domain_pol = q_u->domain_pol;
- uint32 user_rid = q_u->user_rid;
- POLICY_HND *user_pol = &r_u->user_pol;
+ SAM_ACCOUNT *sampass=NULL;
+ DOM_SID sid;
+ POLICY_HND domain_pol = q_u->domain_pol;
+ uint32 user_rid = q_u->user_rid;
+ POLICY_HND *user_pol = &r_u->user_pol;
struct samr_info *info = NULL;
+ BOOL ret;
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
- /* find the domain policy handle. */
- if (!find_policy_by_hnd(p, &domain_pol, NULL))
- return NT_STATUS_INVALID_HANDLE;
+ /* find the domain policy handle. */
+ if (!find_policy_by_hnd(p, &domain_pol, NULL))
+ return NT_STATUS_INVALID_HANDLE;
- become_root();
- sam_pass = getsam21pwrid(user_rid);
- unbecome_root();
+ pdb_init_sam(&sampass);
- /* check that the RID exists in our domain. */
- if (sam_pass == NULL)
- return NT_STATUS_NO_SUCH_USER;
+ become_root();
+ ret=pdb_getsampwrid(sampass, user_rid);
+ unbecome_root();
- samr_clear_sam_passwd(sam_pass);
+ /* check that the RID exists in our domain. */
+ if (ret == False) {
+ pdb_free_sam(sampass);
+ return NT_STATUS_NO_SUCH_USER;
+ }
- /* Get the domain SID stored in the domain policy */
- if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid))
- return NT_STATUS_INVALID_HANDLE;
+ samr_clear_sam_passwd(sampass);
+ pdb_free_sam(sampass);
- /* append the user's RID to it */
- if(!sid_append_rid(&sid, user_rid))
- return NT_STATUS_NO_SUCH_USER;
+ /* Get the domain SID stored in the domain policy */
+ if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid))
+ return NT_STATUS_INVALID_HANDLE;
- /* associate the user's SID with the new handle. */
- if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL)
- return NT_STATUS_NO_MEMORY;
+ /* append the user's RID to it */
+ if(!sid_append_rid(&sid, user_rid))
+ return NT_STATUS_NO_SUCH_USER;
- ZERO_STRUCTP(info);
- info->sid = sid;
+ /* associate the user's SID with the new handle. */
+ if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL)
+ return NT_STATUS_NO_MEMORY;
- /* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info))
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ ZERO_STRUCTP(info);
+ info->sid = sid;
- return r_u->status;
+ /* get a (unique) handle. open a policy on it. */
+ if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info))
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+
+ return r_u->status;
}
/*************************************************************************
@@ -1457,28 +1501,35 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U
static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid)
{
- struct smb_passwd *smb_pass;
+ SAM_ACCOUNT *smbpass=NULL;
+ BOOL ret;
- if (!pdb_rid_is_user(user_rid)) {
- DEBUG(4,("RID 0x%x is not a user RID\n", user_rid));
- return False;
- }
+ if (!pdb_rid_is_user(user_rid)) {
+ DEBUG(4,("RID 0x%x is not a user RID\n", user_rid));
+ return False;
+ }
- become_root();
- smb_pass = getsmbpwrid(user_rid);
- unbecome_root();
+ pdb_init_sam(&smbpass);
- if (smb_pass == NULL)
- {
- DEBUG(4,("User 0x%x not found\n", user_rid));
- return False;
- }
+ become_root();
+ ret = pdb_getsampwrid(smbpass, user_rid);
+ unbecome_root();
- DEBUG(3,("User:[%s]\n", smb_pass->smb_name));
+ if (ret==False) {
+ DEBUG(4,("User 0x%x not found\n", user_rid));
+ pdb_free_sam(smbpass);
+ return False;
+ }
+
+ DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) ));
- init_sam_user_info10(id10, smb_pass->acct_ctrl);
+ ZERO_STRUCTP(id10);
+ init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) );
- return True;
+ samr_clear_sam_passwd(smbpass);
+ pdb_free_sam(smbpass);
+
+ return True;
}
/*************************************************************************
@@ -1489,7 +1540,8 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid)
static BOOL get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 user_rid)
{
- struct smb_passwd *smb_pass;
+ SAM_ACCOUNT *smbpass=NULL;
+ BOOL ret;
if (!p->ntlmssp_auth_validated)
return NT_STATUS_ACCESS_DENIED;
@@ -1500,95 +1552,106 @@ static BOOL get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 us
/*
* Do *NOT* do become_root()/unbecome_root() here ! JRA.
*/
+ pdb_init_sam(&smbpass);
- smb_pass = getsmbpwrid(user_rid);
+ ret = pdb_getsampwrid(smbpass, user_rid);
- if (smb_pass == NULL) {
+ if (ret == False) {
DEBUG(4, ("User 0x%x not found\n", user_rid));
+ pdb_free_sam(smbpass);
return (geteuid() == (uid_t)0) ? NT_STATUS_NO_SUCH_USER : NT_STATUS_ACCESS_DENIED;
}
- DEBUG(3,("User:[%s] 0x%x\n", smb_pass->smb_name, smb_pass->acct_ctrl));
+ DEBUG(3,("User:[%s] 0x%x\n", pdb_get_username(smbpass), pdb_get_acct_ctrl(smbpass) ));
- if (smb_pass->acct_ctrl & ACB_DISABLED)
- return NT_STATUS_ACCOUNT_DISABLED;
+ if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) {
+ pdb_free_sam(smbpass);
+ return NT_STATUS_ACCOUNT_DISABLED;
+ }
- init_sam_user_info12(id12, smb_pass->smb_passwd, smb_pass->smb_nt_passwd);
+ ZERO_STRUCTP(id12);
+ init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass));
+
+ pdb_free_sam(smbpass);
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
+#if 0 /* JERRY */
/*************************************************************************
- get_user_info_21
+ get_user_info_20
*************************************************************************/
-static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid)
+static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid)
{
- NTTIME dummy_time;
- struct sam_passwd *sam_pass;
- LOGON_HRS hrs;
- int i;
+ SAM_ACCOUNT *sampass=NULL;
+ BOOL ret;
- if (!pdb_rid_is_user(user_rid)) {
- DEBUG(4,("RID 0x%x is not a user RID\n", user_rid));
- return False;
- }
+ if (!pdb_rid_is_user(user_rid)) {
+ DEBUG(4,("RID 0x%x is not a user RID\n", user_rid));
+ return False;
+ }
- become_root();
- sam_pass = getsam21pwrid(user_rid);
- unbecome_root();
+ pdb_init_sam(&sampass);
- if (sam_pass == NULL) {
- DEBUG(4,("User 0x%x not found\n", user_rid));
- return False;
- }
+ become_root();
+ ret = pdb_getsampwrid(sampass, user_rid);
+ unbecome_root();
- samr_clear_sam_passwd(sam_pass);
+ if (ret == False) {
+ DEBUG(4,("User 0x%x not found\n", user_rid));
+ pdb_free_sam(sampass);
+ return False;
+ }
+
+ samr_clear_sam_passwd(sampass);
- DEBUG(3,("User:[%s]\n", sam_pass->smb_name));
+ DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) ));
+
+ ZERO_STRUCTP(id20);
+ init_sam_user_info20A(id20, sampass);
+
+ pdb_free_sam(sampass);
+
+ return True;
+}
+#endif
+/*************************************************************************
+ get_user_info_21
+ *************************************************************************/
- dummy_time.low = 0xffffffff;
- dummy_time.high = 0x7fffffff;
+static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid)
+{
+ SAM_ACCOUNT *sampass=NULL;
+ BOOL ret;
- DEBUG(5,("get_user_info_21 - TODO: convert unix times to NTTIMEs\n"));
+ if (!pdb_rid_is_user(user_rid)) {
+ DEBUG(4,("RID 0x%x is not a user RID\n", user_rid));
+ return False;
+ }
- /* create a LOGON_HRS structure */
- hrs.len = sam_pass->hours_len;
- SMB_ASSERT_ARRAY(hrs.hours, hrs.len);
- for (i = 0; i < hrs.len; i++)
- hrs.hours[i] = sam_pass->hours[i];
+ pdb_init_sam(&sampass);
- init_sam_user_info21A(id21,
+ become_root();
+ ret = pdb_getsampwrid(sampass, user_rid);
+ unbecome_root();
- &dummy_time, /* logon_time */
- &dummy_time, /* logoff_time */
- &dummy_time, /* kickoff_time */
- &dummy_time, /* pass_last_set_time */
- &dummy_time, /* pass_can_change_time */
- &dummy_time, /* pass_must_change_time */
+ if (ret == False) {
+ DEBUG(4,("User 0x%x not found\n", user_rid));
+ pdb_free_sam(sampass);
+ return False;
+ }
- sam_pass->smb_name, /* user_name */
- sam_pass->full_name, /* full_name */
- sam_pass->home_dir, /* home_dir */
- sam_pass->dir_drive, /* dir_drive */
- sam_pass->logon_script, /* logon_script */
- sam_pass->profile_path, /* profile_path */
- sam_pass->acct_desc, /* description */
- sam_pass->workstations, /* workstations user can log in from */
- sam_pass->unknown_str, /* don't know, yet */
- sam_pass->munged_dial, /* dialin info. contains dialin path and tel no */
+ samr_clear_sam_passwd(sampass);
- sam_pass->user_rid, /* RID user_id */
- sam_pass->group_rid, /* RID group_id */
- sam_pass->acct_ctrl,
+ DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) ));
- sam_pass->unknown_3, /* unknown_3 */
- sam_pass->logon_divs, /* divisions per week */
- &hrs, /* logon hours */
- sam_pass->unknown_5,
- sam_pass->unknown_6);
+ ZERO_STRUCTP(id21);
+ init_sam_user_info21A(id21, sampass);
+
+ pdb_free_sam(sampass);
- return True;
+ return True;
}
/*******************************************************************
@@ -1601,7 +1664,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_
uint32 rid = 0;
struct samr_info *info = NULL;
- r_u->status=NT_STATUS_NO_PROBLEMO;
+ r_u->status=NT_STATUS_OK;
/* search for the handle */
if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info))
@@ -1613,7 +1676,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_
DEBUG(5,("_samr_query_userinfo: rid:0x%x\n", rid));
- ctr = (SAM_USERINFO_CTR *)talloc(p->mem_ctx, sizeof(SAM_USERINFO_CTR));
+ ctr = (SAM_USERINFO_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_USERINFO_CTR));
if (!ctr)
return NT_STATUS_NO_MEMORY;
@@ -1624,7 +1687,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_
switch (q_u->switch_value) {
case 0x10:
- ctr->info.id10 = (SAM_USER_INFO_10 *)talloc(p->mem_ctx, sizeof(SAM_USER_INFO_10));
+ ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(p->mem_ctx, sizeof(SAM_USER_INFO_10));
if (ctr->info.id10 == NULL)
return NT_STATUS_NO_MEMORY;
@@ -1642,7 +1705,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_
expire.low = 0xffffffff;
expire.high = 0x7fffffff;
- ctr->info.id = (SAM_USER_INFO_11 *)talloc(p->mem_ctx,
+ ctr->info.id = (SAM_USER_INFO_11 *)talloc_zero(p->mem_ctx,
sizeof
(*ctr->
info.
@@ -1658,16 +1721,16 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_
#endif
case 0x12:
- ctr->info.id12 = (SAM_USER_INFO_12 *)talloc(p->mem_ctx, sizeof(SAM_USER_INFO_12));
+ ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(p->mem_ctx, sizeof(SAM_USER_INFO_12));
if (ctr->info.id12 == NULL)
return NT_STATUS_NO_MEMORY;
- if ((r_u->status = get_user_info_12(p, ctr->info.id12, rid))!=NT_STATUS_NOPROBLEMO)
+ if ((r_u->status = get_user_info_12(p, ctr->info.id12, rid))!=NT_STATUS_OK)
return r_u->status;
break;
case 21:
- ctr->info.id21 = (SAM_USER_INFO_21 *)talloc(p->mem_ctx,sizeof(SAM_USER_INFO_21));
+ ctr->info.id21 = (SAM_USER_INFO_21 *)talloc_zero(p->mem_ctx,sizeof(SAM_USER_INFO_21));
if (ctr->info.id21 == NULL)
return NT_STATUS_NO_MEMORY;
if (!get_user_info_21(ctr->info.id21, rid))
@@ -1691,44 +1754,49 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_
uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u)
{
- struct sam_passwd *sam_pass;
- DOM_GID *gids = NULL;
- int num_groups = 0;
- pstring groups;
- uint32 rid;
+ SAM_ACCOUNT *sam_pass=NULL;
+ DOM_GID *gids = NULL;
+ int num_groups = 0;
+ pstring groups;
+ uint32 rid;
struct samr_info *info = NULL;
+ BOOL ret;
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
- DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__));
+ DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__));
- /* find the policy handle. open a policy on it. */
- if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info))
- return NT_STATUS_INVALID_HANDLE;
+ /* find the policy handle. open a policy on it. */
+ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info))
+ return NT_STATUS_INVALID_HANDLE;
- /* find the user's rid */
- if ((rid = get_lsa_policy_samr_rid(info)) == 0xffffffff)
- return NT_STATUS_OBJECT_TYPE_MISMATCH;
+ /* find the user's rid */
+ if ((rid = get_lsa_policy_samr_rid(info)) == 0xffffffff)
+ return NT_STATUS_OBJECT_TYPE_MISMATCH;
- become_root();
- sam_pass = getsam21pwrid(rid);
- unbecome_root();
+ pdb_init_sam(&sam_pass);
- if (sam_pass == NULL)
- return NT_STATUS_NO_SUCH_USER;
+ become_root();
+ ret = pdb_getsampwrid(sam_pass, rid);
+ unbecome_root();
- samr_clear_sam_passwd(sam_pass);
+ if (ret == False) {
+ samr_clear_sam_passwd(sam_pass);
+ return NT_STATUS_NO_SUCH_USER;
+ }
- get_domain_user_groups(groups, sam_pass->smb_name);
- gids = NULL;
- num_groups = make_dom_gids(p->mem_ctx, groups, &gids);
+ get_domain_user_groups(groups, pdb_get_username(sam_pass));
+ gids = NULL;
+ num_groups = make_dom_gids(p->mem_ctx, groups, &gids);
- /* construct the response. lkclXXXX: gids are not copied! */
- init_samr_r_query_usergroups(r_u, num_groups, gids, r_u->status);
+ /* construct the response. lkclXXXX: gids are not copied! */
+ init_samr_r_query_usergroups(r_u, num_groups, gids, r_u->status);
- DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__));
+ DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__));
+
+ samr_clear_sam_passwd(sam_pass);
- return r_u->status;
+ return r_u->status;
}
/*******************************************************************
@@ -1739,12 +1807,12 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR
{
SAM_UNK_CTR *ctr;
- if ((ctr = (SAM_UNK_CTR *)talloc(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL)
+ if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL)
return NT_STATUS_NO_MEMORY;
ZERO_STRUCTP(ctr);
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__));
@@ -1776,7 +1844,7 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR
return NT_STATUS_INVALID_INFO_CLASS;
}
- init_samr_r_query_dom_info(r_u, q_u->switch_value, ctr, NT_STATUS_NOPROBLEMO);
+ init_samr_r_query_dom_info(r_u, q_u->switch_value, ctr, NT_STATUS_OK);
DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__));
@@ -1789,107 +1857,119 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR
uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u)
{
- struct sam_passwd *sam_pass = NULL;
- fstring mach_acct;
- pstring err_str;
- pstring msg_str;
- int local_flags=0;
- DOM_SID sid;
- pstring add_script;
- POLICY_HND dom_pol = q_u->domain_pol;
- UNISTR2 user_account = q_u->uni_name;
- uint16 acb_info = q_u->acb_info;
- POLICY_HND *user_pol = &r_u->user_pol;
+ SAM_ACCOUNT *sam_pass=NULL;
+ fstring mach_acct;
+ pstring err_str;
+ pstring msg_str;
+ int local_flags=0;
+ DOM_SID sid;
+ pstring add_script;
+ POLICY_HND dom_pol = q_u->domain_pol;
+ UNISTR2 user_account = q_u->uni_name;
+ uint16 acb_info = q_u->acb_info;
+ POLICY_HND *user_pol = &r_u->user_pol;
struct samr_info *info = NULL;
+ BOOL ret;
- /* find the policy handle. open a policy on it. */
- if (!find_policy_by_hnd(p, &dom_pol, NULL))
- return NT_STATUS_INVALID_HANDLE;
+ /* find the policy handle. open a policy on it. */
+ if (!find_policy_by_hnd(p, &dom_pol, NULL))
+ return NT_STATUS_INVALID_HANDLE;
- /* find the machine account: tell the caller if it exists.
- lkclXXXX i have *no* idea if this is a problem or not
- or even if you are supposed to construct a different
- reply if the account already exists...
- */
-
- fstrcpy(mach_acct, dos_unistrn2(user_account.buffer, user_account.uni_str_len));
- strlower(mach_acct);
-
- become_root();
- sam_pass = getsam21pwnam(mach_acct);
- unbecome_root();
- if (sam_pass != NULL) {
- /* machine account exists: say so */
- return NT_STATUS_USER_EXISTS;
- }
+ /* find the machine account: tell the caller if it exists.
+ lkclXXXX i have *no* idea if this is a problem or not
+ or even if you are supposed to construct a different
+ reply if the account already exists...
+ */
- local_flags=LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_SET_NO_PASSWORD;
- local_flags|= (acb_info & ACB_WSTRUST) ? LOCAL_TRUST_ACCOUNT:0;
-
- /*
- * NB. VERY IMPORTANT ! This call must be done as the current pipe user,
- * *NOT* surrounded by a become_root()/unbecome_root() call. This ensures
- * that only people with write access to the smbpasswd file will be able
- * to create a user. JRA.
- */
-
- /*
- * add the user in the /etc/passwd file or the unix authority system.
- * We don't check if the smb_create_user() function succed or not for 2 reasons:
- * a) local_password_change() checks for us if the /etc/passwd account really exists
- * b) smb_create_user() would return an error if the account already exists
- * and as it could return an error also if it can't create the account, it would be tricky.
- *
- * So we go the easy way, only check after if the account exists.
- * JFM (2/3/2001), to clear any possible bad understanding (-:
- */
-
- pstrcpy(add_script, lp_adduser_script());
-
- if(*add_script)
- smb_create_user(mach_acct, NULL);
-
- /* add the user in the smbpasswd file or the Samba authority database */
- if (!local_password_change(mach_acct, local_flags, NULL, err_str,
- sizeof(err_str), msg_str, sizeof(msg_str)))
- {
- DEBUG(0, ("%s\n", err_str));
- return NT_STATUS_ACCESS_DENIED;
- }
+ fstrcpy(mach_acct, dos_unistrn2(user_account.buffer, user_account.uni_str_len));
+ strlower(mach_acct);
- become_root();
- sam_pass = getsam21pwnam(mach_acct);
- unbecome_root();
- if (sam_pass == NULL) {
- /* account doesn't exist: say so */
- return NT_STATUS_ACCESS_DENIED;
- }
+ pdb_init_sam(&sam_pass);
- /* Get the domain SID stored in the domain policy */
- if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) {
- return NT_STATUS_INVALID_HANDLE;
- }
+ become_root();
+ ret = pdb_getsampwnam(sam_pass, mach_acct);
+ unbecome_root();
+ if (ret == True) {
+ /* machine account exists: say so */
+ pdb_free_sam(sam_pass);
+ return NT_STATUS_USER_EXISTS;
+ }
- /* append the user's RID to it */
- if(!sid_append_rid(&sid, sam_pass->user_rid)) {
- return NT_STATUS_NO_SUCH_USER;
- }
+ local_flags=LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_SET_NO_PASSWORD;
+ local_flags|= (acb_info & ACB_WSTRUST) ? LOCAL_TRUST_ACCOUNT:0;
- /* associate the user's SID with the new handle. */
- if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL)
- return NT_STATUS_NO_MEMORY;
+ /*
+ * NB. VERY IMPORTANT ! This call must be done as the current pipe user,
+ * *NOT* surrounded by a become_root()/unbecome_root() call. This ensures
+ * that only people with write access to the smbpasswd file will be able
+ * to create a user. JRA.
+ */
- ZERO_STRUCTP(info);
- info->sid = sid;
+ /*
+ * add the user in the /etc/passwd file or the unix authority system.
+ * We don't check if the smb_create_user() function succed or not for 2 reasons:
+ * a) local_password_change() checks for us if the /etc/passwd account really exists
+ * b) smb_create_user() would return an error if the account already exists
+ * and as it could return an error also if it can't create the account, it would be tricky.
+ *
+ * So we go the easy way, only check after if the account exists.
+ * JFM (2/3/2001), to clear any possible bad understanding (-:
+ */
- /* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info))
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ pstrcpy(add_script, lp_adduser_script());
+
+ if(*add_script)
+ smb_create_user(mach_acct, NULL);
+ /* add the user in the smbpasswd file or the Samba authority database */
+ if (!local_password_change(mach_acct, local_flags, NULL, err_str,
+ sizeof(err_str), msg_str, sizeof(msg_str))) {
+ DEBUG(0, ("%s\n", err_str));
+ pdb_free_sam(sam_pass);
+ return NT_STATUS_ACCESS_DENIED;
+ }
- r_u->user_rid=sam_pass->user_rid;
- r_u->unknown_0 = 0x000703ff;
+ become_root();
+ ret = pdb_getsampwnam(sam_pass, mach_acct);
+ unbecome_root();
+ if (ret == False) {
+ /* account doesn't exist: say so */
+ pdb_free_sam(sam_pass);
+ return NT_STATUS_ACCESS_DENIED;
+ }
- return NT_STATUS_NO_PROBLEMO;
+ /* Get the domain SID stored in the domain policy */
+ if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) {
+ pdb_free_sam(sam_pass);
+ return NT_STATUS_INVALID_HANDLE;
+ }
+
+ /* append the user's RID to it */
+ if(!sid_append_rid(&sid, pdb_get_user_rid(sam_pass) )) {
+ pdb_free_sam(sam_pass);
+ return NT_STATUS_NO_SUCH_USER;
+ }
+
+ /* associate the user's SID with the new handle. */
+ if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) {
+ pdb_free_sam(sam_pass);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ZERO_STRUCTP(info);
+ info->sid = sid;
+
+ /* get a (unique) handle. open a policy on it. */
+ if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) {
+ pdb_free_sam(sam_pass);
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
+ r_u->user_rid=sam_pass->user_rid;
+ r_u->unknown_0 = 0x000703ff;
+
+ pdb_free_sam(sam_pass);
+
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -1902,7 +1982,7 @@ uint32 _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONN
/* set up the SAMR connect_anon response */
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* associate the user's SID with the new handle. */
if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL)
@@ -1928,7 +2008,7 @@ uint32 _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u)
DEBUG(5,("_samr_connect: %d\n", __LINE__));
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* associate the user's SID with the new handle. */
if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL)
@@ -1952,7 +2032,7 @@ uint32 _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u)
uint32 _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u)
{
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL))
return NT_STATUS_INVALID_HANDLE;
@@ -1983,8 +2063,8 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam,
if (num_sam_entries == 0)
return True;
- sam = (SAM_ENTRY *)talloc(ctx, sizeof(SAM_ENTRY)*num_sam_entries);
- uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2)*num_sam_entries);
+ sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_sam_entries);
+ uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_sam_entries);
if (sam == NULL || uni_name == NULL)
return False;
@@ -2011,7 +2091,7 @@ uint32 _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM
uint32 num_entries = 2;
fstring dom[2];
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
fstrcpy(dom[0],global_myworkgroup);
fstrcpy(dom[1],"Builtin");
@@ -2036,7 +2116,7 @@ uint32 _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN
POLICY_HND *alias_pol = &r_u->pol;
struct samr_info *info = NULL;
- r_u->status = NT_STATUS_NO_PROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* get the domain policy. */
if (!find_policy_by_hnd(p, &domain_pol, NULL))
@@ -2075,23 +2155,32 @@ uint32 _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN
static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid)
{
- struct sam_passwd *pwd = getsam21pwrid(rid);
- struct sam_passwd new_pwd;
+ SAM_ACCOUNT *pwd =NULL;
+ BOOL ret;
+
+ pdb_init_sam(&pwd);
+
+ ret = pdb_getsampwrid(pwd, rid);
+
+ if(ret==False) {
+ pdb_free_sam(pwd);
+ return False;
+ }
if (id10 == NULL) {
DEBUG(5, ("set_user_info_10: NULL id10\n"));
+ pdb_free_sam(pwd);
return False;
}
- if (pwd == NULL)
- return False;
-
- copy_sam_passwd(&new_pwd, pwd);
-
- new_pwd.acct_ctrl = id10->acb_info;
+ pdb_set_acct_ctrl(pwd, id10->acb_info);
- if(!mod_sam21pwd_entry(&new_pwd, True))
+ if(!pdb_update_sam_account(pwd, True)) {
+ pdb_free_sam(pwd);
return False;
+ }
+
+ pdb_free_sam(pwd);
return True;
}
@@ -2102,31 +2191,36 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid)
static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid)
{
- struct sam_passwd *pwd = getsam21pwrid(rid);
- struct sam_passwd new_pwd;
- static uchar nt_hash[16];
- static uchar lm_hash[16];
+ SAM_ACCOUNT *pwd = NULL;
- if (pwd == NULL)
+ pdb_init_sam(&pwd);
+
+ if(!pdb_getsampwrid(pwd, rid)) {
+ pdb_free_sam(pwd);
return False;
+ }
if (id12 == NULL) {
DEBUG(2, ("set_user_info_12: id12 is NULL\n"));
+ pdb_free_sam(pwd);
return False;
}
-
- pdb_init_sam(&new_pwd);
- copy_sam_passwd(&new_pwd, pwd);
-
- memcpy(nt_hash, id12->nt_pwd, sizeof(nt_hash));
- memcpy(lm_hash, id12->lm_pwd, sizeof(lm_hash));
-
- new_pwd.smb_passwd = lm_hash;
- new_pwd.smb_nt_passwd = nt_hash;
-
- if(!mod_sam21pwd_entry(&new_pwd, True))
+
+ if (!pdb_set_lanman_passwd (pwd, id12->lm_pwd)) {
+ pdb_free_sam(pwd);
+ return False;
+ }
+ if (!pdb_set_nt_passwd(pwd, id12->nt_pwd)) {
+ pdb_free_sam(pwd);
return False;
+ }
+
+ if(!pdb_update_sam_account(pwd, True)) {
+ pdb_free_sam(pwd);
+ return False;
+ }
+ pdb_free_sam(pwd);
return True;
}
@@ -2136,39 +2230,44 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid)
static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid)
{
- struct sam_passwd *pwd = getsam21pwrid(rid);
- struct sam_passwd new_pwd;
- static uchar nt_hash[16];
- static uchar lm_hash[16];
-
+ SAM_ACCOUNT *pwd = NULL;
+ SAM_ACCOUNT *new_pwd = NULL;
+
if (id21 == NULL) {
DEBUG(5, ("set_user_info_21: NULL id21\n"));
return False;
}
-
- if (pwd == NULL)
- return False;
-
+
+ pdb_init_sam(&pwd);
pdb_init_sam(&new_pwd);
- /* we make a copy so that we can modify stuff */
- copy_sam_passwd(&new_pwd, pwd);
- copy_id21_to_sam_passwd(&new_pwd, id21);
-
- if (pwd->smb_nt_passwd != NULL) {
- memcpy(nt_hash, pwd->smb_nt_passwd, 16);
- new_pwd.smb_nt_passwd = nt_hash;
- } else
- new_pwd.smb_nt_passwd = NULL;
-
- if (pwd->smb_nt_passwd != NULL) {
- memcpy(lm_hash, pwd->smb_passwd, 16);
- new_pwd.smb_passwd = lm_hash;
- } else
- new_pwd.smb_passwd = NULL;
-
- if(!mod_sam21pwd_entry(&new_pwd, True))
+
+ if (!pdb_getsampwrid(pwd, rid)) {
+ pdb_free_sam(pwd);
+ pdb_free_sam(new_pwd);
return False;
-
+ }
+
+ /* we make a copy so that we can modify stuff */
+ copy_sam_passwd(new_pwd, pwd);
+ copy_id21_to_sam_passwd(new_pwd, id21);
+
+ /*
+ * The funny part about the previous two calls is
+ * that pwd still has the password hashes from the
+ * passdb entry. These have not been updated from
+ * id21. I don't know if they need to be set. --jerry
+ */
+
+ /* write the change out */
+ if(!pdb_update_sam_account(new_pwd, True)) {
+ pdb_free_sam(pwd);
+ pdb_free_sam(new_pwd);
+ return False;
+ }
+
+ pdb_free_sam(pwd);
+ pdb_free_sam(new_pwd);
+
return True;
}
@@ -2178,51 +2277,72 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid)
static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
{
- struct sam_passwd *pwd = getsam21pwrid(rid);
- struct sam_passwd new_pwd;
- static uchar nt_hash[16];
- static uchar lm_hash[16];
+ SAM_ACCOUNT *pwd = NULL;
+ SAM_ACCOUNT *new_pwd = NULL;
+ uint8 nt_hash[16];
+ uint8 lm_hash[16];
pstring buf;
uint32 len;
-
+ uint16 acct_ctrl;
+
if (id23 == NULL) {
DEBUG(5, ("set_user_info_23: NULL id23\n"));
return False;
}
-
- if (pwd == NULL)
- return False;
-
+
+ pdb_init_sam(&pwd);
pdb_init_sam(&new_pwd);
- copy_sam_passwd(&new_pwd, pwd);
- copy_id23_to_sam_passwd(&new_pwd, id23);
-
- memset(buf, 0, sizeof(pstring));
-
- if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len, nt_hash, lm_hash))
+
+ if (!pdb_getsampwrid(pwd, rid)) {
+ pdb_free_sam(pwd);
+ pdb_free_sam(new_pwd);
return False;
+ }
- new_pwd.smb_passwd = lm_hash;
- new_pwd.smb_nt_passwd = nt_hash;
+ acct_ctrl = pdb_get_acct_ctrl(pwd);
+ copy_sam_passwd(new_pwd, pwd);
+ pdb_free_sam(pwd);
+
+ copy_id23_to_sam_passwd(new_pwd, id23);
+
+ if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len, nt_hash, lm_hash)) {
+ pdb_free_sam(new_pwd);
+ return False;
+ }
+
+ if (!pdb_set_lanman_passwd (new_pwd, lm_hash)) {
+ pdb_free_sam(new_pwd);
+ return False;
+ }
+ if (!pdb_set_nt_passwd(new_pwd, nt_hash)) {
+ pdb_free_sam(new_pwd);
+ return False;
+ }
+
/* if it's a trust account, don't update /etc/passwd */
- if ( ( (new_pwd.acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) ||
- ( (new_pwd.acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) ||
- ( (new_pwd.acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) {
+ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) ||
+ ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) ||
+ ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) {
DEBUG(5, ("Changing trust account password, not updating /etc/passwd\n"));
- } else {
-
+ } else {
/* update the UNIX password */
if (lp_unix_password_sync() )
- if(!chgpasswd(new_pwd.smb_name, "", buf, True))
+ if(!chgpasswd(pdb_get_username(new_pwd), "", buf, True)) {
+ pdb_free_sam(new_pwd);
return False;
+ }
}
-
+
memset(buf, 0, sizeof(buf));
-
- if(!mod_sam21pwd_entry(&new_pwd, True))
+
+ if(!pdb_update_sam_account(new_pwd, True)) {
+ pdb_free_sam(new_pwd);
return False;
-
+ }
+
+ pdb_free_sam(new_pwd);
+
return True;
}
@@ -2232,47 +2352,63 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
static BOOL set_user_info_pw(char *pass, uint32 rid)
{
- struct sam_passwd *pwd = getsam21pwrid(rid);
- struct sam_passwd new_pwd;
- static uchar nt_hash[16];
- static uchar lm_hash[16];
+ SAM_ACCOUNT *pwd = NULL;
+ uchar nt_hash[16];
+ uchar lm_hash[16];
uint32 len;
pstring buf;
-
- if (pwd == NULL)
+ uint16 acct_ctrl;
+
+ pdb_init_sam(&pwd);
+
+ if (!pdb_getsampwrid(pwd, rid)) {
+ pdb_free_sam(pwd);
return False;
+ }
+
+ acct_ctrl = pdb_get_acct_ctrl(pwd);
- pdb_init_sam(&new_pwd);
- copy_sam_passwd(&new_pwd, pwd);
-
- memset(buf, 0, sizeof(pstring));
-
- if (!decode_pw_buffer(pass, buf, 256, &len, nt_hash, lm_hash))
+ memset(buf, 0, sizeof(buf));
+
+ if (!decode_pw_buffer(pass, buf, 256, &len, nt_hash, lm_hash)) {
+ pdb_free_sam(pwd);
return False;
+ }
- new_pwd.smb_passwd = lm_hash;
- new_pwd.smb_nt_passwd = nt_hash;
-
+ if (!pdb_set_lanman_passwd (pwd, lm_hash)) {
+ pdb_free_sam(pwd);
+ return False;
+ }
+ if (!pdb_set_nt_passwd(pwd, nt_hash)) {
+ pdb_free_sam(pwd);
+ return False;
+ }
+
/* if it's a trust account, don't update /etc/passwd */
- if ( ( (new_pwd.acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) ||
- ( (new_pwd.acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) ||
- ( (new_pwd.acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) {
+ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) ||
+ ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) ||
+ ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) {
DEBUG(5, ("Changing trust account password, not updating /etc/passwd\n"));
} else {
-
/* update the UNIX password */
- if (lp_unix_password_sync() )
- if(!chgpasswd(new_pwd.smb_name, "", buf, True))
+ if (lp_unix_password_sync())
+ if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) {
+ pdb_free_sam(pwd);
return False;
+ }
}
-
+
memset(buf, 0, sizeof(buf));
-
+
DEBUG(5,("set_user_info_pw: pdb_update_sam_account()\n"));
-
+
/* update the SAMBA password */
- if(!mod_sam21pwd_entry(&new_pwd, True))
+ if(!pdb_update_sam_account(pwd, True)) {
+ pdb_free_sam(pwd);
return False;
+ }
+
+ pdb_free_sam(pwd);
return True;
}
@@ -2286,15 +2422,16 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_
uint32 rid = 0x0;
DOM_SID sid;
struct current_user user;
- struct smb_passwd *smb_pass;
+ SAM_ACCOUNT *sam_pass=NULL;
unsigned char sess_key[16];
POLICY_HND *pol = &q_u->pol;
uint16 switch_value = q_u->switch_value;
SAM_USERINFO_CTR *ctr = q_u->ctr;
+ BOOL ret;
DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__));
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
if (p->ntlmssp_auth_validated) {
memcpy(&user, &p->pipe_user, sizeof(user));
@@ -2317,6 +2454,8 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_
}
+ pdb_init_sam(&sam_pass);
+
/*
* We need the NT hash of the user who is changing the user's password.
* This NT hash is used to generate a "user session key"
@@ -2324,21 +2463,18 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_
*/
become_root();
- smb_pass = getsmbpwuid(user.uid);
+ ret = pdb_getsampwuid(sam_pass, user.uid);
unbecome_root();
- if(smb_pass == NULL) {
+ if(ret == False) {
DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd entry for uid %u\n", (unsigned int)user.uid ));
+ pdb_free_sam(sam_pass);
return NT_STATUS_ACCESS_DENIED;
}
-
- if (smb_pass->smb_nt_passwd == NULL) {
- DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd NT password entry entry for uid %u\n",
- (unsigned int)user.uid ));
- return NT_STATUS_ACCESS_DENIED;
- }
-
+
memset(sess_key, '\0', 16);
- mdfour(sess_key, smb_pass->smb_nt_passwd, 16);
+ mdfour(sess_key, pdb_get_nt_passwd(sam_pass), 16);
+
+ pdb_free_sam(sam_pass);
/* ok! user info levels (lots: see MSDEV help), off we go... */
switch (switch_value) {
@@ -2352,7 +2488,7 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_
dump_data(100, (char *)ctr->info.id24->pass, 516);
- if (!set_user_info_pw((char *)(ctr->info.id24->pass), rid))
+ if (!set_user_info_pw((char *)ctr->info.id24->pass, rid))
return NT_STATUS_ACCESS_DENIED;
break;
@@ -2406,7 +2542,7 @@ uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SE
DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__));
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
/* find the policy handle. open a policy on it. */
if (!get_lsa_policy_samr_sid(p, pol, &sid))
@@ -2451,8 +2587,21 @@ uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SE
uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u)
{
- DEBUG(0,("_samr_query_useraliases: Not yet implemented.\n"));
- return False;
+ uint32 *rid=NULL;
+ int num_rids;
+
+ num_rids = 1;
+ rid=(uint32 *)talloc_zero(p->mem_ctx, num_rids*sizeof(uint32));
+ if (rid == NULL)
+ return NT_STATUS_NO_MEMORY;
+
+ /* until i see a real useraliases query, we fack one up */
+
+ rid[0] = BUILTIN_ALIAS_RID_USERS;
+
+ init_samr_r_query_useraliases(r_u, num_rids, rid, NT_STATUS_OK);
+
+ return r_u->status;
}
/*********************************************************************
@@ -2592,7 +2741,7 @@ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SE
uint32 _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_GET_DOM_PWINFO *r_u)
{
/* Actually, returning zeros here works quite well :-). */
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/*********************************************************************
diff --git a/source/rpc_server/srv_spoolss.c b/source/rpc_server/srv_spoolss.c
index 63bbc5f87b7..011efb1bace 100755
--- a/source/rpc_server/srv_spoolss.c
+++ b/source/rpc_server/srv_spoolss.c
@@ -1110,7 +1110,7 @@ static BOOL api_spoolss_addprintprocessor(pipes_struct *p)
automatically set the winprint processor for printer
entries later. Used to debug the LexMark Optra S 1855 PCL
driver --jerry */
- r_u.status = NT_STATUS_NO_PROBLEMO;
+ r_u.status = NT_STATUS_OK;
if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) {
DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n"));
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index 3fcb08891df..86f4fe77ac3 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -22,6 +22,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/* Since the SPOOLSS rpc routines are basically DOS 16-bit calls wrapped
+ up, all the errors returned are DOS errors, not NT status codes. */
+
#include "includes.h"
extern int DEBUGLEVEL;
@@ -31,6 +34,7 @@ extern pstring global_myname;
#define MAX_OPEN_PRINTER_EXS 50
#endif
+#define PHANTOM_DEVMODE_KEY "_p_f_a_n_t_0_m_"
#define PRINTER_HANDLE_IS_PRINTER 0
#define PRINTER_HANDLE_IS_PRINTSERVER 1
@@ -272,12 +276,12 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
if (!Printer) {
DEBUG(0,("delete_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
if (del_a_printer(Printer->dev.handlename) != 0) {
DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
/* Check calling user has permission to delete printer. Note that
@@ -287,7 +291,7 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
if (!print_access_check(NULL, -1, PRINTER_ACCESS_ADMINISTER)) {
DEBUG(3, ("printer delete denied by security descriptor\n"));
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
if (*lp_deleteprinter_cmd()) {
@@ -305,7 +309,7 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
DEBUG(10,("Running [%s]\n", command));
ret = smbrun(command, NULL);
if (ret != 0) {
- return ERROR_INVALID_HANDLE; /* What to return here? */
+ return ERRbadfid; /* What to return here? */
}
DEBUGADD(10,("returned [%d]\n", ret));
@@ -314,12 +318,12 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) {
lp_killservice( i );
- return ERROR_SUCCESS;
+ return ERRsuccess;
} else
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
- return ERROR_SUCCESS;
+ return ERRsuccess;
}
/****************************************************************************
@@ -706,7 +710,7 @@ static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle)
uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u)
{
#if 0
- uint32 result = NT_STATUS_NO_PROBLEMO;
+ uint32 result = ERRsuccess;
#endif
UNISTR2 *printername = NULL;
@@ -723,7 +727,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u,
printername = &q_u->printername;
if (printername == NULL)
- return ERROR_INVALID_PRINTER_NAME;
+ return ERRinvalidprintername;
/* some sanity check because you can open a printer or a print server */
/* aka: \\server\printer or \\server */
@@ -732,7 +736,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u,
DEBUGADD(3,("checking name: %s\n",name));
if (!open_printer_hnd(p, handle, name))
- return ERROR_INVALID_PRINTER_NAME;
+ return ERRinvalidprintername;
/*
if (printer_default->datatype_ptr != NULL)
@@ -746,7 +750,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u,
if (!set_printer_hnd_accesstype(p, handle, printer_default->access_required)) {
close_printer_handle(p, handle);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
/*
@@ -776,7 +780,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u,
if (handle_is_printserver(p, handle)) {
if (printer_default->access_required == 0) {
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) {
@@ -785,14 +789,14 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u,
if (!lp_ms_add_printer_wizard()) {
close_printer_handle(p, handle);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) {
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
else {
close_printer_handle(p, handle);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
}
}
@@ -802,16 +806,29 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u,
doesn't have print permission. */
if (!get_printer_snum(p, handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
/* map an empty access mask to the minimum access mask */
if (printer_default->access_required == 0x0)
printer_default->access_required = PRINTER_ACCESS_USE;
+
+
+ /*
+ * If we are not serving the printer driver for this printer,
+ * map PRINTER_ACCESS_ADMINISTER to PRINTER_ACCESS_USE. This
+ * will keep NT clients happy --jerry
+ */
+
+ if (lp_use_client_driver(snum)
+ && (printer_default->access_required & PRINTER_ACCESS_ADMINISTER))
+ {
+ printer_default->access_required = PRINTER_ACCESS_USE;
+ }
if (!print_access_check(&user, snum, printer_default->access_required)) {
DEBUG(3, ("access DENIED for printer open\n"));
close_printer_handle(p, handle);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
/*
@@ -890,7 +907,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u,
#endif
}
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -1008,7 +1025,7 @@ static uint32 _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handl
if (!Printer) {
DEBUG(0,("_spoolss_enddocprinter_internal: Invalid handle (%s)\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
Printer->document_started=False;
@@ -1034,9 +1051,9 @@ uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R
memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle));
if (!close_printer_handle(p, handle))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -1058,7 +1075,7 @@ uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL
result = delete_printer_handle(p, handle);
- if (result == ERROR_SUCCESS) {
+ if (result == ERRsuccess) {
srv_spoolss_sendnotify(p, handle);
}
@@ -1120,20 +1137,20 @@ uint32 _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER
/* check that we have a valid driver name first */
if ((version=get_version_id(arch)) == -1) {
/* this is what NT returns */
- return ERROR_INVALID_ENVIRONMENT;
+ return ERRinvalidenvironment;
}
ZERO_STRUCT(info);
if (get_a_printer_driver (&info, 3, driver, arch, version) != 0) {
/* this is what NT returns */
- return ERROR_UNKNOWN_PRINTER_DRIVER;
+ return ERRunknownprinterdriver;
}
if (printer_driver_in_use(arch, driver))
{
/* this is what NT returns */
- return ERROR_PRINTER_DRIVER_IN_USE;
+ return ERRprinterdriverinuse;
}
return delete_printer_driver(info.info_3);
@@ -1309,9 +1326,9 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO
if (!Printer) {
if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
unistr2_to_ascii(value, valuename, sizeof(value)-1);
@@ -1326,18 +1343,18 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO
/* reply this param doesn't exist */
if (*out_size) {
if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
} else {
*data = NULL;
}
- return ERROR_INVALID_PARAMETER;
+ return ERRinvalidparam;
}
if (*needed > *out_size)
- return ERROR_MORE_DATA;
+ return ERRmoredata;
else {
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
}
@@ -1399,7 +1416,7 @@ uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE
if (!Printer) {
DEBUG(0,("_spoolss_rffpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
Printer->notify.flags=flags;
@@ -1419,7 +1436,7 @@ uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE
&Printer->notify.client_hnd))
Printer->notify.client_connected=True;
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/*******************************************************************
@@ -2209,7 +2226,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int
uint16 type;
uint16 field;
- SPOOL_NOTIFY_INFO_DATA *current_data;
+ SPOOL_NOTIFY_INFO_DATA *current_data, *tid;
NT_PRINTER_INFO_LEVEL *printer = NULL;
print_queue_struct *queue=NULL;
@@ -2228,10 +2245,13 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int
if (!search_notify(type, field, &j) )
continue;
-
- if((info->data=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
+
+ if((tid=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
+ DEBUG(0,("construct_notify_printer_info: failed to enlarge buffer info->data!\n"));
return False;
}
+ else info->data = tid;
+
current_data=&info->data[info->count];
construct_info_data(current_data, type, field, id);
@@ -2265,7 +2285,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue,
uint16 type;
uint16 field;
- SPOOL_NOTIFY_INFO_DATA *current_data;
+ SPOOL_NOTIFY_INFO_DATA *current_data, *tid;
DEBUG(4,("construct_notify_jobs_info\n"));
@@ -2281,9 +2301,11 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue,
if (!search_notify(type, field, &j) )
continue;
- if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
+ if((tid=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
+ DEBUG(0,("construct_notify_jobs_info: failed to enlarg buffer info->data!\n"));
return False;
- }
+ } else
+ info->data = tid;
current_data=&(info->data[info->count]);
@@ -2374,7 +2396,7 @@ static uint32 printserver_notify_info(pipes_struct *p, POLICY_HND *hnd,
}
*/
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/*******************************************************************
@@ -2457,7 +2479,7 @@ static uint32 printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY
info->data[i].id, info->data[i].size, info->data[i].enc_type));
}
*/
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -2472,7 +2494,7 @@ uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN
SPOOL_NOTIFY_INFO *info = &r_u->info;
Printer_entry *Printer=find_printer_index_by_hnd(p, handle);
- uint32 result = ERROR_INVALID_HANDLE;
+ uint32 result = ERRbadfid;
/* we always have a NOTIFY_INFO struct */
r_u->info_ptr=0x1;
@@ -2886,7 +2908,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of
int snum;
int i;
int n_services=lp_numservices();
- PRINTER_INFO_1 *printers=NULL;
+ PRINTER_INFO_1 *tp, *printers=NULL;
PRINTER_INFO_1 current_prt;
DEBUG(4,("enum_all_printers_info_1\n"));
@@ -2896,10 +2918,13 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
if (construct_printer_info_1(flags, &current_prt, snum)) {
- if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) {
+ if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) {
+ DEBUG(0,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
+ safe_free(printers);
*returned=0;
- return ERROR_NOT_ENOUGH_MEMORY;
- }
+ return ERRnomem;
+ } else
+ printers = tp;
DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned));
memcpy(&printers[*returned], &current_prt, sizeof(PRINTER_INFO_1));
(*returned)++;
@@ -2912,7 +2937,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of
(*needed) += spoolss_size_printer_info_1(&printers[i]);
if (!alloc_buffer_size(buffer, *needed))
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
/* fill the buffer with the structures */
for (i=0; i<*returned; i++)
@@ -2923,10 +2948,10 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -2954,7 +2979,7 @@ static BOOL enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint
return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned);
}
else
- return ERROR_INVALID_NAME;
+ return ERRinvalidname;
}
/********************************************************************
@@ -2976,7 +3001,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui
*/
if((printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
*returned=1;
@@ -2994,7 +3019,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(printer);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3005,10 +3030,10 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3033,7 +3058,7 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32
int snum;
int i;
int n_services=lp_numservices();
- PRINTER_INFO_2 *printers=NULL;
+ PRINTER_INFO_2 *tp, *printers=NULL;
PRINTER_INFO_2 current_prt;
for (snum=0; snum<n_services; snum++) {
@@ -3041,8 +3066,13 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
if (construct_printer_info_2(&current_prt, snum)) {
- if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) {
+ DEBUG(0,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
+ safe_free(printers);
+ *returned = 0;
+ return ERRnomem;
+ } else
+ printers = tp;
DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned));
memcpy(&printers[*returned], &current_prt, sizeof(PRINTER_INFO_2));
(*returned)++;
@@ -3059,7 +3089,7 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32
free_devmode(printers[i].devmode);
}
safe_free(printers);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3074,10 +3104,10 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3101,7 +3131,7 @@ static uint32 enumprinters_level1( uint32 flags, fstring name,
if (flags & PRINTER_ENUM_NETWORK)
return enum_all_printers_info_1_network(buffer, offered, needed, returned);
- return NT_STATUS_NO_PROBLEMO; /* NT4sp5 does that */
+ return ERRsuccess; /* NT4sp5 does that */
}
/********************************************************************
@@ -3127,13 +3157,13 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername,
if (strequal(servername, temp))
return enum_all_printers_info_2(buffer, offered, needed, returned);
else
- return ERROR_INVALID_NAME;
+ return ERRinvalidname;
}
if (flags & PRINTER_ENUM_REMOTE)
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3144,7 +3174,7 @@ static uint32 enumprinters_level5( uint32 flags, fstring servername,
uint32 *needed, uint32 *returned)
{
/* return enum_all_printers_info_5(buffer, offered, needed, returned);*/
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3200,7 +3230,7 @@ uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_
case 3:
case 4:
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -3211,7 +3241,7 @@ static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u
PRINTER_INFO_0 *printer=NULL;
if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
construct_printer_info_0(printer, snum);
@@ -3220,7 +3250,7 @@ static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(printer);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3230,10 +3260,10 @@ static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u
safe_free(printer);
if (*needed > offered) {
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3243,7 +3273,7 @@ static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u
PRINTER_INFO_1 *printer=NULL;
if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum);
@@ -3252,7 +3282,7 @@ static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(printer);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3262,10 +3292,10 @@ static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u
safe_free(printer);
if (*needed > offered) {
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3275,7 +3305,7 @@ static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u
PRINTER_INFO_2 *printer=NULL;
if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
construct_printer_info_2(printer, snum);
@@ -3284,23 +3314,23 @@ static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u
if (!alloc_buffer_size(buffer, *needed)) {
free_printer_info_2(printer);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
if (!smb_io_printer_info_2("", buffer, printer, 0)) {
free_printer_info_2(printer);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
/* clear memory */
free_printer_info_2(printer);
if (*needed > offered) {
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3310,14 +3340,14 @@ static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u
PRINTER_INFO_3 *printer=NULL;
if (!construct_printer_info_3(&printer, snum))
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
/* check the required size. */
*needed += spoolss_size_printer_info_3(printer);
if (!alloc_buffer_size(buffer, *needed)) {
free_printer_info_3(printer);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3327,10 +3357,10 @@ static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u
free_printer_info_3(printer);
if (*needed > offered) {
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3353,7 +3383,7 @@ uint32 _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET
*needed=0;
if (!get_printer_snum(p, handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
switch (level) {
case 0:
@@ -3365,7 +3395,7 @@ uint32 _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET
case 3:
return getprinter_level_3(snum, buffer, offered, needed);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -3388,16 +3418,16 @@ static uint32 construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst
ZERO_STRUCT(driver);
if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0)
- return ERROR_INVALID_PRINTER_NAME;
+ return ERRinvalidprintername;
if (get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version) != 0)
- return ERROR_UNKNOWN_PRINTER_DRIVER;
+ return ERRunknownprinterdriver;
fill_printer_driver_info_1(info, driver, servername, architecture);
free_a_printer(&printer,2);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3446,16 +3476,16 @@ static uint32 construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst
ZERO_STRUCT(driver);
if (!get_a_printer(&printer, 2, lp_servicename(snum)) != 0)
- return ERROR_INVALID_PRINTER_NAME;
+ return ERRinvalidprintername;
if (!get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version) != 0)
- return ERROR_UNKNOWN_PRINTER_DRIVER;
+ return ERRunknownprinterdriver;
fill_printer_driver_info_2(info, driver, servername);
free_a_printer(&printer,2);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3469,6 +3499,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser
int j=0;
char *v;
pstring line;
+ uint16 *tuary;
DEBUG(6,("init_unistr_array\n"));
*uni_array=NULL;
@@ -3483,10 +3514,11 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser
if (strlen(v) == 0) break;
slprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v);
DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line)));
- if((*uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) {
+ if((tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) {
DEBUG(0,("init_unistr_array: Realloc error\n" ));
return;
- }
+ } else
+ *uni_array = tuary;
j += (dos_PutUniCode((char *)(*uni_array+j), line , sizeof(uint16)*strlen(line), True) / sizeof(uint16) );
i++;
}
@@ -3558,20 +3590,20 @@ static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst
status=get_a_printer(&printer, 2, lp_servicename(snum) );
DEBUG(8,("construct_printer_driver_info_3: status: %d\n", status));
if (status != 0)
- return ERROR_INVALID_PRINTER_NAME;
+ return ERRinvalidprintername;
status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
DEBUG(8,("construct_printer_driver_info_3: status: %d\n", status));
if (status != 0) {
free_a_printer(&printer,2);
- return ERROR_UNKNOWN_PRINTER_DRIVER;
+ return ERRunknownprinterdriver;
}
fill_printer_driver_info_3(info, driver, servername);
free_a_printer(&printer,2);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3652,7 +3684,7 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst
status=get_a_printer(&printer, 2, lp_servicename(snum) );
DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status));
if (status != 0)
- return ERROR_INVALID_PRINTER_NAME;
+ return ERRinvalidprintername;
status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status));
@@ -3663,7 +3695,7 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst
if (version < 3) {
free_a_printer(&printer,2);
- return ERROR_UNKNOWN_PRINTER_DRIVER;
+ return ERRunknownprinterdriver;
}
/* Yes - try again with a WinNT driver. */
@@ -3672,7 +3704,7 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst
DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status));
if (status != 0) {
free_a_printer(&printer,2);
- return ERROR_UNKNOWN_PRINTER_DRIVER;
+ return ERRunknownprinterdriver;
}
}
@@ -3680,7 +3712,7 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst
free_a_printer(&printer,2);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3708,10 +3740,10 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture,
uint32 status;
if((info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
status=construct_printer_driver_info_1(info, snum, servername, architecture, version);
- if (status != NT_STATUS_NO_PROBLEMO) {
+ if (status != ERRsuccess) {
safe_free(info);
return status;
}
@@ -3721,7 +3753,7 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture,
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(info);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3731,9 +3763,9 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture,
safe_free(info);
if (*needed > offered)
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3744,10 +3776,10 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture,
uint32 status;
if((info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
status=construct_printer_driver_info_2(info, snum, servername, architecture, version);
- if (status != NT_STATUS_NO_PROBLEMO) {
+ if (status != ERRsuccess) {
safe_free(info);
return status;
}
@@ -3757,7 +3789,7 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture,
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(info);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3767,9 +3799,9 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture,
safe_free(info);
if (*needed > offered)
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3782,7 +3814,7 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture,
ZERO_STRUCT(info);
status=construct_printer_driver_info_3(&info, snum, servername, architecture, version);
- if (status != NT_STATUS_NO_PROBLEMO) {
+ if (status != ERRsuccess) {
return status;
}
@@ -3791,7 +3823,7 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture,
if (!alloc_buffer_size(buffer, *needed)) {
free_printer_driver_info_3(&info);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3800,9 +3832,9 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture,
free_printer_driver_info_3(&info);
if (*needed > offered)
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3815,7 +3847,7 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture,
ZERO_STRUCT(info);
status=construct_printer_driver_info_6(&info, snum, servername, architecture, version);
- if (status != NT_STATUS_NO_PROBLEMO) {
+ if (status != ERRsuccess) {
return status;
}
@@ -3824,7 +3856,7 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture,
if (!alloc_buffer_size(buffer, *needed)) {
free_printer_driver_info_6(&info);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -3833,9 +3865,9 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture,
free_printer_driver_info_6(&info);
if (*needed > offered)
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -3872,7 +3904,7 @@ uint32 _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_
unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1);
if (!get_printer_snum(p, handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
switch (level) {
case 1:
@@ -3884,7 +3916,7 @@ uint32 _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_
case 6:
return getprinterdriver2_level6(servername, architecture, clientmajorversion, snum, buffer, offered, needed);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -3903,7 +3935,7 @@ uint32 _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u,
}
DEBUG(3,("Error in startpageprinter printer handle\n"));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
/****************************************************************************
@@ -3917,12 +3949,12 @@ uint32 _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO
if (!Printer) {
DEBUG(0,("_spoolss_endpageprinter: Invalid handle (%s).\n",OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
Printer->page_started=False;
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/********************************************************************
@@ -3947,7 +3979,7 @@ uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S
if (!Printer) {
DEBUG(0,("_spoolss_startdocprinter: Invalid handle (%s)\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
get_current_user(&user, p);
@@ -3968,13 +4000,13 @@ uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S
unistr2_to_ascii(datatype, &info_1->datatype, sizeof(datatype));
if (strcmp(datatype, "RAW") != 0) {
(*jobid)=0;
- return ERROR_INVALID_DATATYPE;
+ return ERRinvaliddatatype;
}
}
/* get the share number of the printer */
if (!get_printer_snum(p, handle, &snum)) {
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname));
@@ -4022,7 +4054,7 @@ uint32 _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R
if (!Printer) {
DEBUG(0,("_spoolss_writeprinter: Invalid handle (%s)\n",OUR_HANDLE(handle)));
r_u->buffer_written = q_u->buffer_size2;
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
(*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, buffer_size);
@@ -4042,18 +4074,18 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command,
pipes_struct *p)
{
struct current_user user;
- int snum, errcode = ERROR_INVALID_FUNCTION;
+ int snum, errcode = ERRbadfunc;
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
get_current_user(&user, p);
if (!Printer) {
DEBUG(0,("control_printer: Invalid handle (%s)\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
if (!get_printer_snum(p, handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
switch (command) {
case PRINTER_CONTROL_PAUSE:
@@ -4073,7 +4105,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command,
}
break;
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
return errcode;
@@ -4109,7 +4141,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level,
DEBUG(0,("update_printer_sec: Invalid handle (%s)\n",
OUR_HANDLE(handle)));
- result = ERROR_INVALID_HANDLE;
+ result = ERRbadfid;
goto done;
}
@@ -4159,7 +4191,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level,
new_secdesc_ctr = sec_desc_merge(p->mem_ctx, secdesc_ctr, old_secdesc_ctr);
if (sec_desc_equal(new_secdesc_ctr->sec, old_secdesc_ctr->sec)) {
- result = NT_STATUS_NO_PROBLEMO;
+ result = ERRsuccess;
goto done;
}
@@ -4173,7 +4205,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level,
information. */
if (!print_access_check(&user, snum, PRINTER_ACCESS_ADMINISTER)) {
- result = ERROR_ACCESS_DENIED;
+ result = ERRnoaccess;
goto done;
}
@@ -4519,28 +4551,28 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
DEBUG(8,("update_printer\n"));
- result = NT_STATUS_NO_PROBLEMO;
+ result = ERRsuccess;
if (level!=2) {
DEBUG(0,("Send a mail to samba@samba.org\n"));
DEBUGADD(0,("with the following message: update_printer: level!=2\n"));
- result = ERROR_INVALID_LEVEL;
+ result = ERRunknownlevel;
goto done;
}
if (!Printer) {
- result = ERROR_INVALID_HANDLE;
+ result = ERRbadfid;
goto done;
}
if (!get_printer_snum(p, handle, &snum)) {
- result = ERROR_INVALID_HANDLE;
+ result = ERRbadfid;
goto done;
}
if((get_a_printer(&printer, 2, lp_servicename(snum)) != 0) ||
(get_a_printer(&old_printer, 2, lp_servicename(snum)) != 0)) {
- result = ERROR_INVALID_HANDLE;
+ result = ERRbadfid;
goto done;
}
@@ -4561,7 +4593,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
DEBUGADD(8,("Converting the devicemode struct\n"));
if (!convert_devicemode(printer->info_2->printername, devmode,
&printer->info_2->devmode)) {
- result = ERROR_NOT_ENOUGH_MEMORY;
+ result = ERRnomem;
goto done;
}
}
@@ -4569,7 +4601,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
/* Do sanity check on the requested changes for Samba */
if (!check_printer_ok(printer->info_2, snum)) {
- result = ERROR_INVALID_PARAMETER;
+ result = ERRinvalidparam;
goto done;
}
@@ -4579,7 +4611,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
if (nt_printer_info_level_equal(printer, old_printer)) {
DEBUG(3, ("printer info has not changed\n"));
- result = NT_STATUS_NO_PROBLEMO;
+ result = ERRsuccess;
goto done;
}
@@ -4588,7 +4620,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) {
DEBUG(3, ("printer property change denied by security "
"descriptor\n"));
- result = ERROR_ACCESS_DENIED;
+ result = ERRnoaccess;
goto done;
}
@@ -4596,7 +4628,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
if (*lp_addprinter_cmd() )
if ( !add_printer_hook(printer) ) {
- result = ERROR_ACCESS_DENIED;
+ result = ERRnoaccess;
goto done;
}
@@ -4604,7 +4636,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
if (add_a_printer(*printer, 2)!=0) {
/* I don't really know what to return here !!! */
- result = ERROR_ACCESS_DENIED;
+ result = ERRnoaccess;
goto done;
}
@@ -4633,7 +4665,7 @@ uint32 _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET
if (!Printer) {
DEBUG(0,("_spoolss_setprinter: Invalid handle (%s)\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
/* check the level */
@@ -4646,7 +4678,7 @@ uint32 _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET
return update_printer_sec(handle, level, info, p,
secdesc_ctr);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -4661,7 +4693,7 @@ uint32 _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u)
if (!Printer) {
DEBUG(0,("_spoolss_fcpn: Invalid handle (%s)\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
if (Printer->notify.client_connected==True)
@@ -4675,7 +4707,7 @@ uint32 _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u)
free_spool_notify_option(&Printer->notify.option);
Printer->notify.client_connected=False;
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -4687,7 +4719,7 @@ uint32 _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u
spoolss_move_buffer(q_u->buffer, &r_u->buffer);
r_u->needed = 0;
- return ERROR_INVALID_PARAMETER; /* this is what a NT server
+ return ERRinvalidparam; /* this is what a NT server
returns for AddJob. AddJob
must fail on non-local
printers */
@@ -4784,7 +4816,7 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum,
if (info==NULL) {
safe_free(queue);
*returned=0;
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
for (i=0; i<*returned; i++)
@@ -4798,7 +4830,7 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum,
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(info);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -4810,10 +4842,10 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum,
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -4830,12 +4862,12 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum,
info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2));
if (info==NULL) {
*returned=0;
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) {
*returned = 0;
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
for (i=0; i<*returned; i++)
@@ -4850,7 +4882,7 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum,
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(info);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the structures */
@@ -4865,10 +4897,10 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum,
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -4902,14 +4934,14 @@ uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO
*returned=0;
if (!get_printer_snum(p, handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
*returned = print_queue_status(snum, &queue, &prt_status);
DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message));
if (*returned == 0) {
safe_free(queue);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
switch (level) {
@@ -4920,7 +4952,7 @@ uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO
default:
safe_free(queue);
*returned=0;
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -4945,16 +4977,16 @@ uint32 _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u
struct current_user user;
print_status_struct prt_status;
- int snum, errcode = ERROR_INVALID_FUNCTION;
+ int snum, errcode = ERRbadfunc;
memset(&prt_status, 0, sizeof(prt_status));
if (!get_printer_snum(p, handle, &snum)) {
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
if (!print_job_exists(jobid)) {
- return ERROR_INVALID_PRINTER_NAME;
+ return ERRinvalidprintername;
}
get_current_user(&user, p);
@@ -4978,7 +5010,7 @@ uint32 _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u
}
break;
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
return errcode;
@@ -4995,7 +5027,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture
fstring *list = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
- DRIVER_INFO_1 *driver_info_1=NULL;
+ DRIVER_INFO_1 *tdi1, *driver_info_1=NULL;
*returned=0;
@@ -5007,13 +5039,16 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture
DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version));
if(ndrivers == -1)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
if(ndrivers != 0) {
- if((driver_info_1=(DRIVER_INFO_1 *)Realloc(driver_info_1, (*returned+ndrivers) * sizeof(DRIVER_INFO_1))) == NULL) {
+ if((tdi1=(DRIVER_INFO_1 *)Realloc(driver_info_1, (*returned+ndrivers) * sizeof(DRIVER_INFO_1))) == NULL) {
+ DEBUG(0,("enumprinterdrivers_level1: failed to enlarge driver info buffer!\n"));
+ safe_free(driver_info_1);
safe_free(list);
- return ERROR_NOT_ENOUGH_MEMORY;
- }
+ return ERRnomem;
+ } else
+ driver_info_1 = tdi1;
}
for (i=0; i<ndrivers; i++) {
@@ -5040,7 +5075,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(driver_info_1);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the driver structures */
@@ -5053,10 +5088,10 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -5070,7 +5105,7 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture
fstring *list = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
- DRIVER_INFO_2 *driver_info_2=NULL;
+ DRIVER_INFO_2 *tdi2, *driver_info_2=NULL;
*returned=0;
@@ -5082,13 +5117,16 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture
DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version));
if(ndrivers == -1)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
if(ndrivers != 0) {
- if((driver_info_2=(DRIVER_INFO_2 *)Realloc(driver_info_2, (*returned+ndrivers) * sizeof(DRIVER_INFO_2))) == NULL) {
+ if((tdi2=(DRIVER_INFO_2 *)Realloc(driver_info_2, (*returned+ndrivers) * sizeof(DRIVER_INFO_2))) == NULL) {
+ DEBUG(0,("enumprinterdrivers_level2: failed to enlarge driver info buffer!\n"));
+ safe_free(driver_info_2);
safe_free(list);
- return ERROR_NOT_ENOUGH_MEMORY;
- }
+ return ERRnomem;
+ } else
+ driver_info_2 = tdi2;
}
for (i=0; i<ndrivers; i++) {
@@ -5116,7 +5154,7 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(driver_info_2);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the form structures */
@@ -5129,10 +5167,10 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -5146,7 +5184,7 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture
fstring *list = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
- DRIVER_INFO_3 *driver_info_3=NULL;
+ DRIVER_INFO_3 *tdi3, *driver_info_3=NULL;
*returned=0;
@@ -5158,13 +5196,16 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture
DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version));
if(ndrivers == -1)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
if(ndrivers != 0) {
- if((driver_info_3=(DRIVER_INFO_3 *)Realloc(driver_info_3, (*returned+ndrivers) * sizeof(DRIVER_INFO_3))) == NULL) {
+ if((tdi3=(DRIVER_INFO_3 *)Realloc(driver_info_3, (*returned+ndrivers) * sizeof(DRIVER_INFO_3))) == NULL) {
+ DEBUG(0,("enumprinterdrivers_level3: failed to enlarge driver info buffer!\n"));
+ safe_free(driver_info_3);
safe_free(list);
- return ERROR_NOT_ENOUGH_MEMORY;
- }
+ return ERRnomem;
+ } else
+ driver_info_3 = tdi3;
}
for (i=0; i<ndrivers; i++) {
@@ -5192,7 +5233,7 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(driver_info_3);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the driver structures */
@@ -5208,10 +5249,10 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -5253,7 +5294,7 @@ uint32 _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS
default:
*returned=0;
safe_free(list);
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -5305,13 +5346,13 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF
DEBUGADD(5,("Number of user forms [%d]\n", *numofforms));
*numofforms += numbuiltinforms;
- if (*numofforms == 0) return ERROR_NO_MORE_ITEMS;
+ if (*numofforms == 0) return ERRnomoreitems;
switch (level) {
case 1:
if ((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) {
*numofforms=0;
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
/* construct the list of form structures */
@@ -5343,7 +5384,7 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF
if (!alloc_buffer_size(buffer, buffer_size)){
safe_free(forms_1);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the form structures */
@@ -5360,15 +5401,15 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF
if (*needed > offered) {
*numofforms=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
default:
safe_free(list);
safe_free(builtinlist);
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -5409,7 +5450,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *
DEBUGADD(5,("Number of forms [%d]\n", numofforms));
if (numofforms == 0)
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
switch (level) {
@@ -5432,7 +5473,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *
safe_free(list);
if (i == numofforms) {
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
}
/* check the required size. */
@@ -5440,22 +5481,22 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *
*needed=spoolss_size_form_1(&form_1);
if (!alloc_buffer_size(buffer, buffer_size)){
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
if (*needed > offered) {
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the form structures */
DEBUGADD(6,("adding form %s [%d] to buffer\n", form_name, i));
smb_io_form_1("", buffer, &form_1, 0);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
default:
safe_free(list);
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -5503,7 +5544,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (fd != -1)
close(fd);
/* Is this the best error to return here? */
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
numlines = 0;
@@ -5513,9 +5554,9 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if(numlines) {
if((ports=(PORT_INFO_1 *)malloc( numlines * sizeof(PORT_INFO_1) )) == NULL) {
- DEBUG(10,("Returning ERROR_NOT_ENOUGH_MEMORY [%x]\n", ERROR_NOT_ENOUGH_MEMORY));
+ DEBUG(10,("Returning ERRnomem [%x]\n", ERRnomem));
file_lines_free(qlines);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
for (i=0; i<numlines; i++) {
@@ -5532,7 +5573,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
*returned = 1; /* Sole Samba port returned. */
if((ports=(PORT_INFO_1 *)malloc( sizeof(PORT_INFO_1) )) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
DEBUG(10,("enumports_level_1: port name %s\n", SAMBA_PRINTER_PORT_NAME));
@@ -5547,7 +5588,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(ports);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the ports structures */
@@ -5560,10 +5601,10 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -5601,7 +5642,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (fd != -1)
close(fd);
/* Is this the best error to return here? */
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
numlines = 0;
@@ -5611,9 +5652,9 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if(numlines) {
if((ports=(PORT_INFO_2 *)malloc( numlines * sizeof(PORT_INFO_2) )) == NULL) {
- DEBUG(10,("Returning ERROR_NOT_ENOUGH_MEMORY [%x]\n", ERROR_NOT_ENOUGH_MEMORY));
+ DEBUG(10,("Returning ERRnomem [%x]\n", ERRnomem));
file_lines_free(qlines);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
for (i=0; i<numlines; i++) {
@@ -5631,7 +5672,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
*returned = 1;
if((ports=(PORT_INFO_2 *)malloc( sizeof(PORT_INFO_2) )) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
DEBUG(10,("enumports_level_2: port name %s\n", SAMBA_PRINTER_PORT_NAME));
@@ -5646,7 +5687,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(ports);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
/* fill the buffer with the ports structures */
@@ -5659,10 +5700,10 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -5693,7 +5734,7 @@ uint32 _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM
case 2:
return enumports_level_2(buffer, offered, needed, returned);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -5711,7 +5752,7 @@ static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) {
DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n"));
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
ZERO_STRUCTP(printer);
@@ -5722,7 +5763,7 @@ static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
if (*lp_addprinter_cmd() )
if ( !add_printer_hook(printer) ) {
free_a_printer(&printer,2);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname,
@@ -5730,13 +5771,13 @@ static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) {
free_a_printer(&printer,2);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
/* you must be a printer admin to add a new printer */
if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) {
free_a_printer(&printer,2);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
/*
@@ -5745,27 +5786,34 @@ static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
if (!check_printer_ok(printer->info_2, snum)) {
free_a_printer(&printer,2);
- return ERROR_INVALID_PARAMETER;
+ return ERRinvalidparam;
}
+ /*
+ * When a printer is created, the drivername bound to the printer is used
+ * to lookup previously saved driver initialization info, which is then
+ * bound to the new printer, simulating what happens in the Windows arch.
+ */
+ set_driver_init(printer, 2);
+
/* write the ASCII on disk */
if (add_a_printer(*printer, 2) != 0) {
free_a_printer(&printer,2);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
if (!open_printer_hnd(p, handle, name)) {
/* Handle open failed - remove addition. */
del_a_printer(printer->info_2->sharename);
free_a_printer(&printer,2);
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
free_a_printer(&printer,2);
srv_spoolss_sendnotify(p, handle);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -5788,13 +5836,13 @@ uint32 _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_
case 1:
/* we don't handle yet */
/* but I know what to do ... */
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
case 2:
return spoolss_addprinterex_level_2(p, uni_srv_name, info,
unk0, unk1, unk2, unk3,
user_switch, user, handle);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -5807,7 +5855,7 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u,
uint32 level = q_u->level;
SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info;
- uint32 err = NT_STATUS_NO_PROBLEMO;
+ uint32 err = ERRsuccess;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
struct current_user user;
@@ -5818,18 +5866,18 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u,
convert_printer_driver_info(info, &driver, level);
DEBUG(5,("Cleaning driver's information\n"));
- if ((err = clean_up_driver_struct(driver, level, &user)) != NT_STATUS_NO_PROBLEMO )
+ if ((err = clean_up_driver_struct(driver, level, &user)) != ERRsuccess )
goto done;
DEBUG(5,("Moving driver to final destination\n"));
if(!move_driver_to_download_area(driver, level, &user, &err)) {
if (err == 0)
- err = ERROR_ACCESS_DENIED;
+ err = ERRnoaccess;
goto done;
}
if (add_a_printer_driver(driver, level)!=0) {
- err = ERROR_ACCESS_DENIED;
+ err = ERRnoaccess;
goto done;
}
@@ -5856,11 +5904,11 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen
unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1);
- if (get_short_archi(short_archi, long_archi)==FALSE)
- return ERROR_INVALID_ENVIRONMENT;
+ if (get_short_archi(short_archi, long_archi)==False)
+ return ERRinvalidenvironment;
if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi);
@@ -5872,7 +5920,7 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(info);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
smb_io_driverdir_1("", buffer, info, 0);
@@ -5880,9 +5928,9 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen
safe_free(info);
if (*needed > offered)
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -5909,7 +5957,7 @@ uint32 _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI
case 1:
return getprinterdriverdir_level_1(name, uni_environment, buffer, offered, needed);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -5959,14 +6007,14 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
if (!Printer) {
DEBUG(0,("_spoolss_enumprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
if (!get_printer_snum(p,handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0)
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
/*
* The NT machine wants to know the biggest size of value and data
@@ -5989,7 +6037,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) {
safe_free(data);
free_a_printer(&printer, 2);
- return ERROR_NO_MORE_ITEMS;
+ return ERRnomoreitems;
}
#endif
@@ -6020,7 +6068,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
if (param_index == 0) {
/* No parameters found. */
free_a_printer(&printer, 2);
- return ERROR_NO_MORE_ITEMS;
+ return ERRnomoreitems;
}
/* the value is an UNICODE string but realvaluesize is the length in bytes including the leading 0 */
@@ -6030,7 +6078,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
DEBUG(6,("final values: [%d], [%d]\n", *out_value_len, *out_data_len));
free_a_printer(&printer, 2);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/*
@@ -6041,7 +6089,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) {
safe_free(data);
free_a_printer(&printer, 2);
- return ERROR_NO_MORE_ITEMS;
+ return ERRnomoreitems;
}
free_a_printer(&printer, 2);
@@ -6058,7 +6106,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
*out_max_value_len=(in_value_len/sizeof(uint16));
if((*out_value=(uint16 *)talloc_zero(p->mem_ctx,in_value_len*sizeof(uint8))) == NULL) {
safe_free(data);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
*out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True);
@@ -6069,7 +6117,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
*out_max_data_len=in_data_len;
if((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) {
safe_free(data);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
memcpy(*data_out, data, (size_t)data_len);
@@ -6077,7 +6125,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S
safe_free(data);
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -6103,22 +6151,41 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP
if (!Printer) {
DEBUG(0,("_spoolss_setprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
if (!get_printer_snum(p,handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
+
+ ZERO_STRUCT(old_param);
+
+ /*
+ * Access check : NT returns "access denied" if you make a
+ * SetPrinterData call without the necessary privildge.
+ * we were originally returning OK if nothing changed
+ * which made Win2k issue **a lot** of SetPrinterData
+ * when connecting to a printer --jerry
+ */
+
+ if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) {
+ DEBUG(3, ("security descriptor change denied by existing "
+ "security descriptor\n"));
+ status = ERRnoaccess;
+ goto done;
+ }
+
+
+ /* Check if we are making any changes or not. Return true if
+ nothing is actually changing. This is not needed anymore but
+ has been left in as an optimization to keep from from
+ writing to disk as often --jerry */
status = get_a_printer(&printer, 2, lp_servicename(snum));
if (status != 0x0)
- return ERROR_INVALID_NAME;
+ return ERRinvalidname;
convert_specific_param(&param, value , type, data, real_len);
- /* Check if we are making any changes or not. Return true if
- nothing is actually changing. */
-
- ZERO_STRUCT(old_param);
if (get_specific_param(*printer, 2, param->value, &old_param.data,
&old_param.type, (uint32 *)&old_param.data_len)) {
@@ -6129,24 +6196,28 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP
old_param.data_len) == 0) {
DEBUG(3, ("setprinterdata hasn't changed\n"));
- status = NT_STATUS_NO_PROBLEMO;
+ status = ERRsuccess;
goto done;
}
}
- /* Access check */
-
- if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) {
- DEBUG(3, ("security descriptor change denied by existing "
- "security descriptor\n"));
- status = ERROR_ACCESS_DENIED;
- goto done;
- }
-
unlink_specific_param_if_exist(printer->info_2, param);
- add_a_specific_param(printer->info_2, &param);
- status = mod_a_printer(*printer, 2);
+ /*
+ * When client side code sets a magic printer data key, detect it and save
+ * the current printer data and the magic key's data (its the DEVMODE) for
+ * future printer/driver initializations.
+ */
+ if (param->type==3 && !strcmp( param->value, PHANTOM_DEVMODE_KEY)) {
+ /*
+ * Set devmode and printer initialization info
+ */
+ status = save_driver_init(printer, 2, param);
+ }
+ else {
+ add_a_specific_param(printer->info_2, &param);
+ status = mod_a_printer(*printer, 2);
+ }
done:
free_a_printer(&printer, 2);
@@ -6175,27 +6246,27 @@ uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_
if (!Printer) {
DEBUG(0,("_spoolss_deleteprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
if (!get_printer_snum(p, handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) {
DEBUG(3, ("_spoolss_deleteprinterdata: printer properties "
"change denied by existing security descriptor\n"));
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
status = get_a_printer(&printer, 2, lp_servicename(snum));
if (status != 0x0)
- return ERROR_INVALID_NAME;
+ return ERRinvalidname;
ZERO_STRUCTP(&param);
unistr2_to_ascii(param.value, value, sizeof(param.value)-1);
if(!unlink_specific_param_if_exist(printer->info_2, &param))
- status = ERROR_INVALID_PARAMETER;
+ status = ERRinvalidparam;
else
status = mod_a_printer(*printer, 2);
@@ -6221,17 +6292,17 @@ uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM
if (!Printer) {
DEBUG(0,("_spoolss_addform: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
/* can't add if builtin */
if (get_a_builtin_ntform(&form->name,&tmpForm)) {
- return ERROR_INVALID_PARAMETER;
+ return ERRinvalidparam;
}
count=get_ntforms(&list);
if(!add_a_form(&list, form, &count))
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
write_ntforms(&list, count);
safe_free(list);
@@ -6256,17 +6327,17 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE
if (!Printer) {
DEBUG(0,("_spoolss_deleteform: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
/* can't delete if builtin */
if (get_a_builtin_ntform(form_name,&tmpForm)) {
- return ERROR_INVALID_PARAMETER;
+ return ERRinvalidparam;
}
count = get_ntforms(&list);
if(!delete_a_form(&list, form_name, &count, &ret))
- return ERROR_INVALID_PARAMETER;
+ return ERRinvalidparam;
safe_free(list);
@@ -6292,11 +6363,11 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *
if (!Printer) {
DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
}
/* can't set if builtin */
if (get_a_builtin_ntform(&form->name,&tmpForm)) {
- return ERROR_INVALID_PARAMETER;
+ return ERRinvalidparam;
}
count=get_ntforms(&list);
@@ -6316,7 +6387,7 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui
PRINTPROCESSOR_1 *info_1=NULL;
if((info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
(*returned) = 0x1;
@@ -6325,7 +6396,7 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui
*needed += spoolss_size_printprocessor_info_1(info_1);
if (!alloc_buffer_size(buffer, *needed))
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
smb_io_printprocessor_info_1("", buffer, info_1, 0);
@@ -6333,10 +6404,10 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -6372,7 +6443,7 @@ uint32 _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS
case 1:
return enumprintprocessors_level_1(buffer, offered, needed, returned);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -6384,7 +6455,7 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered,
PRINTPROCDATATYPE_1 *info_1=NULL;
if((info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
(*returned) = 0x1;
@@ -6393,7 +6464,7 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered,
*needed += spoolss_size_printprocdatatype_info_1(info_1);
if (!alloc_buffer_size(buffer, *needed))
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
smb_io_printprocdatatype_info_1("", buffer, info_1, 0);
@@ -6401,10 +6472,10 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered,
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -6433,7 +6504,7 @@ uint32 _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT
case 1:
return enumprintprocdatatypes_level_1(buffer, offered, needed, returned);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -6446,7 +6517,7 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint
PRINTMONITOR_1 *info_1=NULL;
if((info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
(*returned) = 0x1;
@@ -6455,7 +6526,7 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint
*needed += spoolss_size_printmonitor_info_1(info_1);
if (!alloc_buffer_size(buffer, *needed))
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
smb_io_printmonitor_info_1("", buffer, info_1, 0);
@@ -6463,10 +6534,10 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -6477,7 +6548,7 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint
PRINTMONITOR_2 *info_2=NULL;
if((info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2))) == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
(*returned) = 0x1;
@@ -6488,7 +6559,7 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint
*needed += spoolss_size_printmonitor_info_2(info_2);
if (!alloc_buffer_size(buffer, *needed))
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
smb_io_printmonitor_info_2("", buffer, info_2, 0);
@@ -6496,10 +6567,10 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint
if (*needed > offered) {
*returned=0;
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -6536,7 +6607,7 @@ uint32 _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_
case 2:
return enumprintmonitors_level_2(buffer, offered, needed, returned);
default:
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
@@ -6552,7 +6623,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin
if (info_1 == NULL) {
safe_free(queue);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
for (i=0; i<count && found==False; i++) {
@@ -6563,8 +6634,8 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin
if (found==False) {
safe_free(queue);
safe_free(info_1);
- /* I shoud reply something else ... I can't find the good one */
- return NT_STATUS_NO_PROBLEMO;
+ /* NT treats not found as bad param... yet another bad choice */
+ return ERRinvalidparam;
}
fill_job_info_1(info_1, &(queue[i-1]), i, snum);
@@ -6575,7 +6646,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(info_1);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
smb_io_job_info_1("", buffer, info_1, 0);
@@ -6583,9 +6654,9 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin
safe_free(info_1);
if (*needed > offered)
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
@@ -6604,7 +6675,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
if (info_2 == NULL) {
safe_free(queue);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
for (i=0; i<count && found==False; i++) {
@@ -6615,13 +6686,13 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
if (found==False) {
safe_free(queue);
safe_free(info_2);
- /* I shoud reply something else ... I can't find the good one */
- return NT_STATUS_NO_PROBLEMO;
+ /* NT treats not found as bad param... yet another bad choice */
+ return ERRinvalidparam;
}
if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) {
safe_free(queue);
- return ERROR_NOT_ENOUGH_MEMORY;
+ return ERRnomem;
}
fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter);
@@ -6633,7 +6704,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
if (!alloc_buffer_size(buffer, *needed)) {
safe_free(info_2);
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
}
smb_io_job_info_2("", buffer, info_2, 0);
@@ -6642,9 +6713,9 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
free(info_2);
if (*needed > offered)
- return ERROR_INSUFFICIENT_BUFFER;
+ return ERRinsufficientbuffer;
else
- return NT_STATUS_NO_PROBLEMO;
+ return ERRsuccess;
}
/****************************************************************************
@@ -6675,7 +6746,7 @@ uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_
*needed=0;
if (!get_printer_snum(p, handle, &snum))
- return ERROR_INVALID_HANDLE;
+ return ERRbadfid;
count = print_queue_status(snum, &queue, &prt_status);
@@ -6689,6 +6760,6 @@ uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_
return getjob_level_2(queue, count, snum, jobid, buffer, offered, needed);
default:
safe_free(queue);
- return ERROR_INVALID_LEVEL;
+ return ERRunknownlevel;
}
}
diff --git a/source/rpc_server/srv_srvsvc_nt.c b/source/rpc_server/srv_srvsvc_nt.c
index b487eb1c824..b50cdf3dc4d 100644
--- a/source/rpc_server/srv_srvsvc_nt.c
+++ b/source/rpc_server/srv_srvsvc_nt.c
@@ -33,7 +33,7 @@ extern pstring global_myname;
Fill in a share info level 1 structure.
********************************************************************/
-static void init_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, int snum)
+static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum)
{
int len_net_name;
pstring net_name;
@@ -42,7 +42,7 @@ static void init_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, int snum)
pstrcpy(net_name, lp_servicename(snum));
pstrcpy(remark, lp_comment(snum));
- pstring_sub(remark,"%S",lp_servicename(snum));
+ standard_sub_conn(p->conn, remark);
len_net_name = strlen(net_name);
/* work out the share type */
@@ -63,7 +63,7 @@ static void init_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, int snum)
Fill in a share info level 2 structure.
********************************************************************/
-static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum)
+static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum)
{
int len_net_name;
pstring net_name;
@@ -74,7 +74,7 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum)
pstrcpy(net_name, lp_servicename(snum));
pstrcpy(remark, lp_comment(snum));
- pstring_sub(remark,"%S",lp_servicename(snum));
+ standard_sub_conn(p->conn, remark);
pstrcpy(path, "C:");
pstrcat(path, lp_pathname(snum));
@@ -125,7 +125,7 @@ BOOL share_info_db_init(void)
char *vstring = "INFO/version";
if (share_tdb && local_pid == sys_getpid()) return True;
- share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, 0, O_RDWR|O_CREAT, 0600);
+ share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
if (!share_tdb) {
DEBUG(0,("Failed to open share info database %s (%s)\n",
lock_path("share_info.tdb"), strerror(errno) ));
@@ -226,7 +226,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC
prs_init(&ps, (uint32)sec_desc_size(psd), mem_ctx, MARSHALL);
- if (!sec_io_desc("nt_printing_setsec", &psd, &ps, 1)) {
+ if (!sec_io_desc("share_security", &psd, &ps, 1)) {
goto out;
}
@@ -307,8 +307,7 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d
TALLOC_CTX *mem_ctx = NULL;
SEC_DESC *psd = NULL;
size_t sd_size;
- struct current_user tmp_user;
- struct current_user *puser = NULL;
+ NT_USER_TOKEN *token = NULL;
user_struct *vuser = get_valid_user_struct(vuid);
BOOL ret = True;
@@ -321,26 +320,12 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d
if (!psd)
goto out;
- ZERO_STRUCT(tmp_user);
- if (vuser) {
- tmp_user.vuid = vuid;
- tmp_user.uid = vuser->uid;
- tmp_user.gid = vuser->gid;
- tmp_user.ngroups = vuser->n_groups;
- tmp_user.groups = vuser->groups;
- tmp_user.nt_user_token = vuser->nt_user_token;
- } else {
- tmp_user.vuid = vuid;
- tmp_user.uid = conn->uid;
- tmp_user.gid = conn->gid;
- tmp_user.ngroups = conn->ngroups;
- tmp_user.groups = conn->groups;
- tmp_user.nt_user_token = conn->nt_user_token;
- }
-
- puser = &tmp_user;
+ if (vuser)
+ token = vuser->nt_user_token;
+ else
+ token = conn->nt_user_token;
- ret = se_access_check(psd, puser, desired_access, &granted, &status);
+ ret = se_access_check(psd, token, desired_access, &granted, &status);
out:
@@ -353,7 +338,7 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d
Fill in a share info level 502 structure.
********************************************************************/
-static void init_srv_share_info_502(TALLOC_CTX *ctx, SRV_SHARE_INFO_502 *sh502, int snum)
+static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum)
{
int len_net_name;
pstring net_name;
@@ -363,12 +348,14 @@ static void init_srv_share_info_502(TALLOC_CTX *ctx, SRV_SHARE_INFO_502 *sh502,
uint32 type;
SEC_DESC *sd;
size_t sd_size;
+ TALLOC_CTX *ctx = p->mem_ctx;
+
ZERO_STRUCTP(sh502);
pstrcpy(net_name, lp_servicename(snum));
pstrcpy(remark, lp_comment(snum));
- pstring_sub(remark,"%S",lp_servicename(snum));
+ standard_sub_conn(p->conn, remark);
pstrcpy(path, "C:");
pstrcat(path, lp_pathname(snum));
@@ -429,12 +416,13 @@ static BOOL is_admin_share(int snum)
Fill in a share info structure.
********************************************************************/
-static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr,
+static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr,
uint32 info_level, uint32 *resume_hnd, uint32 *total_entries, BOOL all_shares)
{
int num_entries = 0;
int num_services = lp_numservices();
int snum;
+ TALLOC_CTX *ctx = p->mem_ctx;
DEBUG(5,("init_srv_share_info_ctr\n"));
@@ -466,7 +454,7 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr,
for (snum = *resume_hnd; snum < num_services; snum++) {
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
- init_srv_share_info_1(&info1[i++], snum);
+ init_srv_share_info_1(p, &info1[i++], snum);
}
}
@@ -483,7 +471,7 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr,
for (snum = *resume_hnd; snum < num_services; snum++) {
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
- init_srv_share_info_2(&info2[i++], snum);
+ init_srv_share_info_2(p, &info2[i++], snum);
}
}
@@ -500,7 +488,7 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr,
for (snum = *resume_hnd; snum < num_services; snum++) {
if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
- init_srv_share_info_502(ctx, &info502[i++], snum);
+ init_srv_share_info_502(p, &info502[i++], snum);
}
}
@@ -520,14 +508,14 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr,
Inits a SRV_R_NET_SHARE_ENUM structure.
********************************************************************/
-static void init_srv_r_net_share_enum(TALLOC_CTX *ctx, SRV_R_NET_SHARE_ENUM *r_n,
+static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n,
uint32 info_level, uint32 resume_hnd, BOOL all)
{
DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__));
- if (init_srv_share_info_ctr(ctx, &r_n->ctr, info_level,
+ if (init_srv_share_info_ctr(p, &r_n->ctr, info_level,
&resume_hnd, &r_n->total_entries, all)) {
- r_n->status = NT_STATUS_NOPROBLEMO;
+ r_n->status = NT_STATUS_OK;
} else {
r_n->status = NT_STATUS_INVALID_INFO_CLASS;
}
@@ -539,10 +527,10 @@ static void init_srv_r_net_share_enum(TALLOC_CTX *ctx, SRV_R_NET_SHARE_ENUM *r_n
Inits a SRV_R_NET_SHARE_GET_INFO structure.
********************************************************************/
-static void init_srv_r_net_share_get_info(TALLOC_CTX *ctx, SRV_R_NET_SHARE_GET_INFO *r_n,
+static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_INFO *r_n,
char *share_name, uint32 info_level)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
int snum;
DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__));
@@ -554,13 +542,13 @@ static void init_srv_r_net_share_get_info(TALLOC_CTX *ctx, SRV_R_NET_SHARE_GET_I
if (snum >= 0) {
switch (info_level) {
case 1:
- init_srv_share_info_1(&r_n->info.share.info1, snum);
+ init_srv_share_info_1(p, &r_n->info.share.info1, snum);
break;
case 2:
- init_srv_share_info_2(&r_n->info.share.info2, snum);
+ init_srv_share_info_2(p, &r_n->info.share.info2, snum);
break;
case 502:
- init_srv_share_info_502(ctx, &r_n->info.share.info502, snum);
+ init_srv_share_info_502(p, &r_n->info.share.info502, snum);
break;
case 1005:
init_srv_share_info_1005(&r_n->info.share.info1005, snum);
@@ -574,7 +562,7 @@ static void init_srv_r_net_share_get_info(TALLOC_CTX *ctx, SRV_R_NET_SHARE_GET_I
status = NT_STATUS_BAD_NETWORK_NAME;
}
- r_n->info.ptr_share_ctr = (status == NT_STATUS_NOPROBLEMO) ? 1 : 0;
+ r_n->info.ptr_share_ctr = (status == NT_STATUS_OK) ? 1 : 0;
r_n->status = status;
}
@@ -694,7 +682,7 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto
static uint32 init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr,
int switch_value, uint32 *resume_hnd, uint32 *total_entries)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__));
ctr->switch_value = switch_value;
@@ -736,7 +724,7 @@ static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n,
else
r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
- if (r_n->status != NT_STATUS_NOPROBLEMO)
+ if (r_n->status != NT_STATUS_OK)
resume_hnd = 0;
init_enum_hnd(&r_n->enum_hnd, resume_hnd);
@@ -850,7 +838,7 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto
static uint32 init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr,
int switch_value, uint32 *resume_hnd, uint32 *total_entries)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__));
ctr->switch_value = switch_value;
@@ -891,7 +879,7 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n,
else
r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries);
- if (r_n->status != NT_STATUS_NOPROBLEMO)
+ if (r_n->status != NT_STATUS_OK)
resume_hnd = 0;
init_enum_hnd(&r_n->enum_hnd, resume_hnd);
@@ -950,7 +938,7 @@ static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *fto
static uint32 init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr,
int switch_value, uint32 *resume_hnd, uint32 *total_entries)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__));
ctr->switch_value = switch_value;
@@ -987,7 +975,7 @@ static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n,
else
r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries));
- if (r_n->status != NT_STATUS_NOPROBLEMO)
+ if (r_n->status != NT_STATUS_OK)
resume_hnd = 0;
init_enum_hnd(&r_n->enum_hnd, resume_hnd);
@@ -999,7 +987,7 @@ net server get info
uint32 _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u)
{
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
SRV_INFO_CTR *ctr = (SRV_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_INFO_CTR));
if (!ctr)
@@ -1056,7 +1044,7 @@ uint32 _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R
/* NT gives "Windows NT error 0xc00000022" if we return
NT_STATUS_ACCESS_DENIED here so just pretend everything is OK. */
- uint32 status = NT_STATUS_NOPROBLEMO;
+ uint32 status = NT_STATUS_OK;
DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__));
@@ -1153,7 +1141,7 @@ uint32 _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
/* Create the list of shares for the response. */
- init_srv_r_net_share_enum(p->mem_ctx, r_u,
+ init_srv_r_net_share_enum(p, r_u,
q_u->ctr.info_level,
get_enum_hnd(&q_u->enum_hnd), True);
@@ -1171,7 +1159,7 @@ uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
/* Create the list of shares for the response. */
- init_srv_r_net_share_enum(p->mem_ctx, r_u,
+ init_srv_r_net_share_enum(p, r_u,
q_u->ctr.info_level,
get_enum_hnd(&q_u->enum_hnd), False);
@@ -1192,7 +1180,7 @@ uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S
/* Create the list of shares for the response. */
unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
- init_srv_r_net_share_get_info(p->mem_ctx, r_u, share_name, q_u->info_level);
+ init_srv_r_net_share_get_info(p, r_u, share_name, q_u->info_level);
DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__));
@@ -1229,9 +1217,7 @@ static char *valid_share_pathname(char *dos_pathname)
if (getcwd(saved_pathname, sizeof(saved_pathname)) == NULL)
return False;
- /* Convert to UNIX charset. */
pstrcpy(unix_pathname, ptr);
- dos_to_unix(unix_pathname, True);
ret = chdir(unix_pathname);
@@ -1266,7 +1252,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
r_u->switch_value = 0;
if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global"))
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
snum = find_service(share_name);
@@ -1276,17 +1262,17 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
/* No change to printer shares. */
if (lp_print_ok(snum))
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
get_current_user(&user,p);
if (user.uid != 0)
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
switch (q_u->info_level) {
case 1:
/* Not enough info in a level 1 to do anything. */
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
case 2:
unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name));
unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
@@ -1301,7 +1287,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
map_generic_share_sd_bits(psd);
break;
case 1005:
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
case 1501:
fstrcpy(pathname, lp_pathname(snum));
fstrcpy(comment, lp_comment(snum));
@@ -1316,7 +1302,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
/* We can only modify disk shares. */
if (type != STYPE_DISKTREE)
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
/* Check if the pathname is valid. */
if (!(ptr = valid_share_pathname( pathname )))
@@ -1334,16 +1320,15 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
if (strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) {
if (!lp_change_share_cmd() || !*lp_change_share_cmd())
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"",
lp_change_share_cmd(), CONFIGFILE, share_name, ptr, comment);
- dos_to_unix(command, True); /* Convert to unix-codepage */
DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command ));
if ((ret = smbrun(command, NULL)) != 0) {
DEBUG(0,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret ));
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
/* Tell everyone we updated smb.conf. */
@@ -1369,7 +1354,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__));
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -1397,18 +1382,18 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
if (user.uid != 0) {
DEBUG(10,("_srv_net_share_add: uid != 0. Access denied.\n"));
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
if (!lp_add_share_cmd() || !*lp_add_share_cmd()) {
DEBUG(10,("_srv_net_share_add: No add share command\n"));
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
switch (q_u->info_level) {
case 1:
/* Not enough info in a level 1 to do anything. */
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
case 2:
unistr2_to_ascii(share_name, &q_u->info.share.info2.info_2_str.uni_netname, sizeof(share_name));
unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name));
@@ -1425,14 +1410,14 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
break;
case 1005:
/* DFS only level. */
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
default:
DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level));
return NT_STATUS_INVALID_INFO_CLASS;
}
if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global"))
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
snum = find_service(share_name);
@@ -1442,7 +1427,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
/* We can only add disk shares. */
if (type != STYPE_DISKTREE)
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
/* Check if the pathname is valid. */
if (!(ptr = valid_share_pathname( pathname )))
@@ -1455,12 +1440,11 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"",
lp_add_share_cmd(), CONFIGFILE, share_name, ptr, comment);
- dos_to_unix(command, True); /* Convert to unix-codepage */
DEBUG(10,("_srv_net_share_add: Running [%s]\n", command ));
if ((ret = smbrun(command, NULL)) != 0) {
DEBUG(0,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret ));
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
if (psd) {
@@ -1480,7 +1464,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -1501,7 +1485,7 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S
unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global"))
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
snum = find_service(share_name);
@@ -1510,24 +1494,23 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S
/* No change to printer shares. */
if (lp_print_ok(snum))
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
get_current_user(&user,p);
if (user.uid != 0)
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
if (!lp_delete_share_cmd() || !*lp_delete_share_cmd())
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"",
lp_delete_share_cmd(), CONFIGFILE, lp_servicename(snum));
- dos_to_unix(command, True); /* Convert to unix-codepage */
DEBUG(10,("_srv_net_share_del: Running [%s]\n", command ));
if ((ret = smbrun(command, NULL)) != 0) {
DEBUG(0,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret ));
- return ERROR_ACCESS_DENIED;
+ return ERRnoaccess;
}
/* Delete the SD in the database. */
@@ -1538,7 +1521,7 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S
lp_killservice(snum);
- return NT_STATUS_NOPROBLEMO;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -1559,7 +1542,7 @@ uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET
r_u->tod = tod;
r_u->ptr_srv_tod = 0x1;
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__));
@@ -1609,7 +1592,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC
ZERO_STRUCT(st);
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname));
@@ -1640,7 +1623,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC
if (!fsp) {
DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename));
- r_u->status = ERROR_ACCESS_DENIED;
+ r_u->status = ERRnoaccess;
goto error_exit;
}
}
@@ -1649,7 +1632,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC
if (sd_size == 0) {
DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename));
- r_u->status = ERROR_ACCESS_DENIED;
+ r_u->status = ERRnoaccess;
goto error_exit;
}
@@ -1698,10 +1681,11 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_
struct current_user user;
fstring user_name;
connection_struct *conn = NULL;
+ BOOL became_user = False;
ZERO_STRUCT(st);
- r_u->status = NT_STATUS_NOPROBLEMO;
+ r_u->status = NT_STATUS_OK;
unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname));
@@ -1719,6 +1703,13 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_
goto error_exit;
}
+ if (!become_user(conn, conn->vuid)) {
+ DEBUG(0,("_srv_net_file_set_secdesc: Can't become connected user!\n"));
+ r_u->status = ERRnoaccess;
+ goto error_exit;
+ }
+ became_user = True;
+
unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename));
unix_convert(filename, conn, NULL, &bad_path, &st);
@@ -1733,7 +1724,7 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_
if (!fsp) {
DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename));
- r_u->status = ERROR_ACCESS_DENIED;
+ r_u->status = ERRnoaccess;
goto error_exit;
}
}
@@ -1742,11 +1733,12 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_
if (ret == False) {
DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename));
- r_u->status = ERROR_ACCESS_DENIED;
+ r_u->status = ERRnoaccess;
goto error_exit;
}
close_file(fsp, True);
+ unbecome_user();
close_cnum(conn, user.vuid);
return r_u->status;
@@ -1756,6 +1748,9 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_
close_file(fsp, True);
}
+ if (became_user)
+ unbecome_user();
+
if (conn)
close_cnum(conn, user.vuid);
@@ -1814,7 +1809,7 @@ uint32 _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D
const char *disk_name;
uint32 resume=get_enum_hnd(&q_u->enum_hnd);
- r_u->status=NT_STATUS_NOPROBLEMO;
+ r_u->status=NT_STATUS_OK;
r_u->total_entries = init_server_disk_enum(&resume);
@@ -1849,7 +1844,7 @@ uint32 _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV
int snum;
fstring share_name;
- r_u->status=NT_STATUS_NOPROBLEMO;
+ r_u->status=NT_STATUS_OK;
switch(q_u->type) {
@@ -1868,7 +1863,7 @@ uint32 _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV
default:
/*unsupported type*/
- r_u->status = ERROR_INVALID_LEVEL;
+ r_u->status = ERRunknownlevel;
break;
}
diff --git a/source/rpc_server/srv_util.c b/source/rpc_server/srv_util.c
index 8f15b7f117b..22e573402e9 100644
--- a/source/rpc_server/srv_util.c
+++ b/source/rpc_server/srv_util.c
@@ -251,8 +251,10 @@ uint32 local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type)
********************************************************************/
uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type)
{
- struct sam_disp_info *disp_info;
+ SAM_ACCOUNT *sampwd=NULL;
int i = 0;
+ BOOL ret;
+
(*type) = SID_NAME_USER;
DEBUG(5,("lookup_user_name: rid: %d", rid));
@@ -263,26 +265,28 @@ uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type)
i++;
}
- if (domain_user_rids[i].rid != 0)
- {
+ if (domain_user_rids[i].rid != 0) {
fstrcpy(user_name, domain_user_rids[i].name);
DEBUG(5,(" = %s\n", user_name));
return 0x0;
}
+ pdb_init_sam(&sampwd);
+
/* ok, it's a user. find the user account */
become_root();
- disp_info = getsamdisprid(rid);
+ ret = pdb_getsampwrid(sampwd, rid);
unbecome_root();
- if (disp_info != NULL)
- {
- fstrcpy(user_name, disp_info->smb_name);
+ if (ret == True) {
+ fstrcpy(user_name, pdb_get_username(sampwd) );
DEBUG(5,(" = %s\n", user_name));
+ pdb_free_sam(sampwd);
return 0x0;
}
DEBUG(5,(" none mapped\n"));
+ pdb_free_sam(sampwd);
return NT_STATUS_NONE_MAPPED;
}
@@ -329,19 +333,24 @@ uint32 local_lookup_alias_rid(char *alias_name, uint32 *rid)
********************************************************************/
uint32 local_lookup_user_rid(char *user_name, uint32 *rid)
{
- struct sam_passwd *sam_pass;
+ SAM_ACCOUNT *sampass=NULL;
+ BOOL ret;
+
(*rid) = 0;
+ pdb_init_sam(&sampass);
+
/* find the user account */
become_root();
- sam_pass = getsam21pwnam(user_name);
+ ret = pdb_getsampwnam(sampass, user_name);
unbecome_root();
- if (sam_pass != NULL)
- {
- (*rid) = sam_pass->user_rid;
+ if (ret == True) {
+ (*rid) = pdb_get_user_rid(sampass);
+ pdb_free_sam(sampass);
return 0x0;
}
+ pdb_free_sam(sampass);
return NT_STATUS_NONE_MAPPED;
}
diff --git a/source/rpc_server/srv_wkssvc_nt.c b/source/rpc_server/srv_wkssvc_nt.c
index 40771d2fb93..c20ebb57067 100644
--- a/source/rpc_server/srv_wkssvc_nt.c
+++ b/source/rpc_server/srv_wkssvc_nt.c
@@ -72,7 +72,7 @@ uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO
return NT_STATUS_NO_MEMORY;
create_wks_info_100(wks100);
- init_wks_r_query_info(r_u, q_u->switch_value, wks100, NT_STATUS_NOPROBLEMO);
+ init_wks_r_query_info(r_u, q_u->switch_value, wks100, NT_STATUS_OK);
DEBUG(5,("_wks_query_info: %d\n", __LINE__));